private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { int itemsCount = 7; xmlReader = XmlReader.Create(new StringReader(e.Result)); feed = SyndicationFeed.Load(xmlReader); List<RSSItem> itemsList = new List<RSSItem>(); if (feed.Items.Count() < 7) { itemsCount = feed.Items.Count(); } for (int i = 0; i <= itemsCount; i++) { RSSItem rssitem = new RSSItem(); rssitem.RSSTitle = feed.Items.ToList()[i].Title.Text; rssitem.RSSLink = feed.Items.ToList()[i].Links[0].Uri; itemsList.Add(rssitem); } RSS.ItemsSource = itemsList; } }
public RSSReader() { InitializeComponent(); rssUri = new Uri("http://www.mayfieldcardinals.net/?feed=rss2"); WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); client.DownloadStringAsync(rssUri); List<RSSItem> itemsList = new List<RSSItem>(); RSSItem rssitem = new RSSItem(); rssitem.RSSTitle = "Connecting to News Feed..."; itemsList.Add(rssitem); RSS.ItemsSource = itemsList; }