Problem consuming a WCF service + Silverlight 4
-
Hello im new to Silverlight and i'm having a problem with consuming a WCF service. i have created a Currentname.cs that i use for databinding. And news.cs where i store the data The problem is when i call the service the it doesn't trigger the "event" and populate the propery Could anyone help?
private ObservableCollection<News> _PrivateNews; public ObservableCollection<News> _News { get { if (_PrivateNews.Count == 0) { getData(); } return _PrivateNews; } set { _PrivateNews = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("News")); } } public void getData() { ServiceReference1.Service1Client newservice = new ServiceReference1.Service1Client(); newservice.GetNewsCompleted += new EventHandler<ServiceReference1.GetNewsCompletedEventArgs>(newservice_GetNewsCompleted); newservice.GetNewsAsync(); } void newservice_GetNewsCompleted(object sender, ServiceReference1.GetNewsCompletedEventArgs e) { ObservableCollection myNews = new ObservableCollection(); foreach (ServiceReference1.P_GetSomeNewsResult x in e.Result) { News n = new News(); n.Header = x.NewsHeader; n.Content = x.News; myNews.Add(n); } _News = myNews; }
modified on Friday, October 22, 2010 8:56 AM
-
Hello im new to Silverlight and i'm having a problem with consuming a WCF service. i have created a Currentname.cs that i use for databinding. And news.cs where i store the data The problem is when i call the service the it doesn't trigger the "event" and populate the propery Could anyone help?
private ObservableCollection<News> _PrivateNews; public ObservableCollection<News> _News { get { if (_PrivateNews.Count == 0) { getData(); } return _PrivateNews; } set { _PrivateNews = value; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("News")); } } public void getData() { ServiceReference1.Service1Client newservice = new ServiceReference1.Service1Client(); newservice.GetNewsCompleted += new EventHandler<ServiceReference1.GetNewsCompletedEventArgs>(newservice_GetNewsCompleted); newservice.GetNewsAsync(); } void newservice_GetNewsCompleted(object sender, ServiceReference1.GetNewsCompletedEventArgs e) { ObservableCollection myNews = new ObservableCollection(); foreach (ServiceReference1.P_GetSomeNewsResult x in e.Result) { News n = new News(); n.Header = x.NewsHeader; n.Content = x.News; myNews.Add(n); } _News = myNews; }
modified on Friday, October 22, 2010 8:56 AM
Looks like you are firing a property change for "News", but your property is called "_News".
-
Looks like you are firing a property change for "News", but your property is called "_News".