Windows Phone“ListBox”ItemsSource

我有一个列表,并希望分配下载的饲料她。 还想说我正在使用我在另一个应用程序中使用的相同代码,但是给出的错误就像这个一样少。 另一个完美。 我会发布几个作为这个来源。 因为如果你不能停留太久。

private void carregaListas() { WebClient webClient = new WebClient(); webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted); webClient.DownloadStringAsync(new System.Uri("http://www.news-medical.net/syndication.axd?format=rss")); } private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { stkLife.Visibility = Visibility.Visible; stbOfLife.Begin(); }); } else { // Save the feed into the State property in case the application is tombstoned. //gridProgressBar.Visibility = Visibility.Collapsed; this.State["feed"] = e.Result; UpdateFeedList(e.Result); } } private void UpdateFeedList(string feedXML) { StringReader stringReader = new StringReader(feedXML); XmlReader xmlReader = XmlReader.Create(stringReader); SyndicationFeed feed = SyndicationFeed.Load(xmlReader); Deployment.Current.Dispatcher.BeginInvoke(() => { feedListBox.ItemsSource = feed.Items; }); } 

错误: “在使用ItemsSource之前,项目集合必须为空。”

XAML代码:

             

我使用过此示例: http : //code.msdn.microsoft.com/wpapps/RSS-Reader-Sample-1702775f