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 http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487167(v=vs.105).aspx http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487167(v=vs.105).aspx Data Binding (WPF) http://msdn.microsoft.com/en-us/library/ms750612(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/ms750612(v=vs.110).aspx Data Binding Overview http://msdn.microsoft.com/en-us/library/ms752347(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/ms752347(v=vs.110).aspx c# - WP7 SyndicationFeed - Stack Overflow http://stackoverflow.com/questions/13863885/wp7-syndicationfeed http://stackoverflow.com/questions/13863885/wp7-syndicationfeed


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

Similar presentations


Ads by Google