Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programering af mobile enheder Windows Phone Rss Feed.

Similar presentations


Presentation on theme: "Programering af mobile enheder Windows Phone Rss Feed."— Presentation transcript:

1 Programering af mobile enheder Windows Phone Rss Feed

2 Reference til System.ServiceModel.Syndication.dll Der findes en færdig klasse til RSS feed, men man skal selv ”fiske” den nødvendig reference til dll for at kunne få tilgang.

3 WebClient kan hente data fra url (text, htlm, xml……) private void buttonLoadRss_Click(object sender, RoutedEventArgs e) { WebClient wc = new WebClient(); wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted); wc.OpenReadAsync(new Uri("http://webtv.eal.dk/rss")); } void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { // metode kaldes når read er færdig // e.Result indeholder i dette tilfælde en stream }

4 RSS feed fås fra XML reader til SyndicationFeed private void buttonLoadRss_Click(object sender, RoutedEventArgs e) { WebClient wc = new WebClient(); wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted); wc.OpenReadAsync(new Uri("http://webtv.eal.dk/rss")); } void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { // System.ServiceModel.Syndication.dll skal hentes via browser using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(e.Result)) { System.ServiceModel.Syndication.SyndicationFeed feed = System.ServiceModel.Syndication.SyndicationFeed.Load(reader); var items = feed.Items; listBox1.ItemsSource = items;// items kan nu fx vises i ListBox }

5 xaml eksempel på listbox med template for databinding til RSS feed

6 Links How to create a basic RSS reader for Windows Phone Data Binding (WPF) Data Binding Overview c# - WP7 SyndicationFeed - Stack Overflow


Download ppt "Programering af mobile enheder Windows Phone Rss Feed."

Similar presentations


Ads by Google