Our first example is a Syndication Reader application with a user interface developed with WPF. The user interface of the WPF application is shown in Figure 48-2.
To use the Syndication API, the assembly System. ServiceModel.Web is referenced with the application. The OnGetFeed () event handler method is set to the Click event of the button showing the Get Feed text. The code needed to read the application is really simple. First, the XML content from the RSS feed is read into the XmlReader class from the System.Xml namespace. Rss20FeedFormatter accepts an XmlReader with the ReadFrom() method. For data-binding, the Feed property that returns a SyndicationFeed is assigned to the DataContext of the Window, and the Feed. Items property that returns IEnumerable<Syndicationltem> is assigned to the DataContext of a DockPanel container.
The XAML code that defines the user interface is shown next. The Title property of the window class is bound to the Title ,Text property of the Syndication Feed to display the title of the feed.
In the XAML code, a DockParam named heading, which contains a Label bound to Title. Text and a Label bound to Description of, .Text, is defined. Because these labels are contained within the DockPanel named feedContent,and feedContent is bound to the Feed. Items property, these labels give title and description information about the current selected item.
A list of items is displayed in listBox that uses an ItemTemplate to bind a label to the Title.
The DockPanel named content” contains a Frame element that binds the Source property to the first link of an item, With that setting, th.e Frame control uses the web browser control to display the content from the link, as shown in Figure 48-2.