Developing Developer.com's Windows 8 Reader

As everyone knows, last week was a huge week for Microsoft, where THE event of the year was held, //build/ 2012. So as you might guess, the next few weeks or so of posts will be related to our recent releases, content from //build/ and the resulting work done by you all with your new //build/ toys... Smiley

So I'm giving you fair warning, the next few weeks or so will be heavy on Windows Phone 8 and Windows 8 [Windows Store Apps]. I hear the sighs already... Come on guys. It's the new shiny and when it's coding for fun done with the new shiny? Tongue Out Plus, having attend //build/ myself as a private attendee, there's a number of things I want to code for my new phone/Surface RT, so am naturally keyed to see these kind of projects.

Anyway, to kick it off, here's a cool looking "reader" class app...

Building the Developer.Com Windows 8 App

I was asked to build a Windows Store Application for the Developer.com Network. This was to be a reader app running on Windows 8. The request was for the first version to provide you (the reader) with a list of posts with summaries, that when selected will allow you to read the full article. The first version of this Win8 application would be limited to reading from just a few of the Developer.com Network sites; CodeGuru.com, Developer.com, DevX.com, HTMLGoodies.com and PHPBuilder.com.

I started this assignment about a week ago. The Windows 8 platform provides quite a few tools that make life easier for us. Today is launch day and the application is built and has been submitted to the Widnows 8 App Store. You should have access to it within a few days. In the meantime, I'll share with you what I built, including the code!

First things first, we need to be able to pull down the rss feeds from the 5 sites.

...

Next we can make use of the SyndicationClient and pull back a complete list of items for the feed using the following method.  This method makes use of async/await programming styles which are quite different from traditional styles.  If you are not familiar with this technique check out the CodeGuru on “Creating and Managing Asynchronous Operations in Windows Runtime (WinRT)”  The purpose for using this technique is to minimize the impact on the user interface thread.

...

SNAGHTMLb85c2a

...

At this point, we are ready to bind the observable collection to the UI elements.  The binding for the CombinedFeed to the UI is fairly normal, create the Resource on the page for the itemsViewSource as shown below:

<CollectionViewSource   x:Name="itemsViewSource"  Source="{Binding Items}"  />

Next, attach the CombinedFeed from above with the

itemViewSource.this.DefaultViewModel["Items"] = CombinedFeed;

For this app we are using a GridView to display the feed items in a horizontal scrolling pattern like other metro style apps.

SNAGHTMLb9651e[4]

...

You may have noticed from the GridView definition above, the itemGridView_ItemClick click handler.  This is essential for allowing the user to click on items and view the full text.  Within the click handler, the GridView provides us with the FeedItem the user clicked on in the e.ClickedItem property.  You will need to cast it back to FeedItem; however, it does provide all of the details we need.  If you want to just send the user to a browser to view the details you could use the following statement.

Windows.System.Launcher.LaunchUriAsync(new Uri(((FeedHandling.FeedItem)e.ClickedItem).URL));

Alternatively you could create a custom page and embed the browser within your app.  If you have access to the full content on the site you may choose to make a secondary call to pull the content.

Conclusion

As you can see from above, the SyndicationClient makes the process of pulling down RSS feeds easy and painless.    Furthermore, combining the techniques of asynchronous programming and XAML data binding you can quickly create a feed reader app to pull down and display one or more feeds and display them in a new way for users.

image

And of course the source is available too. [click though and scroll down to the downloads section for the zip.]

The important point I see in this is that it's not hard to get started creating simple reader apps...

Tags:

Follow the Discussion

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.