Really Simple RSS

Data binding is one the the pillars of XAML development.  Rather than writing code that must execute to copy data from one place to another (i.e., from files to the screen), we define relationships between elements on screen, in-memory, or in files.

A binding defines a source of data and a destination.  In this example, for the source, I define an XmlDataProvider that loads the RSS feed of this blog.  The blog entries of an RSS feed are under the <rss> tag AND the <channel> tag; this is the XPath specified as "rss/channel" I give the XmlDataProvider a name of "RichardsBlog"

  For the destination I use a Listbox.  I must tell the Listbox where the data will come from.  This is called the DataContext which I set to the name "RichardsBlog".  I also must tell the Listbox what data to use for the content of each item.  Within the RSS feed channel, each entry is within the <item> tag and the title is within the <title> tag.  I use these to tell the Listbox that the XPath of the binding is item/title.

<XmlDataProvider x:Key="RichardsBlog" 
     XPath="rss/channel" 
     Source=http://blogs.msdn.com/richard_bailey/rss.aspx>
</XmlDataProvider>

<ListBox DataContext="{StaticResource RichardsBlog}"
         ItemsSource
="{Binding XPath=item/title}"/>
 

 That’s it.  Here is the result.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Really Simple RSS

  1. Unknown says:

    runescape runescape money runescape gold buy runescape money buy runescape gold runescape cheat runescape tip lotro lotro gold lotro golds buy lotro gold buy lotro golds lord of the rings online lord of the rings online gold lotro lotro gold lotro golds buy lotro gold buy lotro golds lord of the rings online lord of the rings online gold runescape runescape money runescape gold buy runescape money buy runescape gold runescape cheats runescape tips guild wars guild wars gold dofus dofus kamas lotro lotro gold guild wars gold guild wars gold guild wars gold maple story maple story mesos maplestory mesos maple story maple story mesos maplestory mesos maple story maple story mesos maplestory mesos runescape runescape money runescape gold buy runescape money buy runescape gold http://www.runescape.com runescape.com runescape items dofus dofus kamas dofus kamas guild wars guild wars guild wars runescape runescape money runescape money runescape gold buy runescape money buy runescape gold runescape.com runescape items

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s