Click here to Skip to main content
15,392,679 members
Articles / Mobile Apps
Posted 31 Jan 2012


56 bookmarked

Codeproject Windows Phone Application

Rate me:
Please Sign up or sign in to vote.
4.95/5 (29 votes)
20 Feb 2012CPOL7 min read
This article aims at building an simple Windows phone 7 application for accessing Codeproject content.


This article tries to build an application (though naive) for accessing Codeproject on Windows phone 7 mobile. The RSS feed supplied by Codeproject is utilized to update the content in the application. I have shamelessly utilized the utility classes written by Arik Poznanski (mentioned in the article “Reading RSS items on Windows Phone 7”) to read the RSS feed.

The source code provided requires VS2010, Windows Phone SDK 7.0 for compiling and Windows phone emulator for simulation purpose. I have utilized MS Expression blend for creating XAML files. If you want to get your hands dirty these are available at:


Codeproject have over 8 million users and the count is increasing at a rapid rate. Many turn to this site to keep up with the ever changing world of software development. And for many more this is the entry point for mastering new concepts, technologies and frameworks. The Q&A section which is most lively helps many to unwind their day to day coding problems and in many cases the seeker never waits for more than 5 minutes (of course if posted in correct way and with correct sense) to get the anwser.

It saddened me a bit to know that a wonderful thing of this kind is not having a mobile application (at least I haven't came across any). And the need to have one is itself open to argument.

Currently Codeproject has a mobile website where many features are trimmed compared to the traditional desktop website. However a link is provided to access the full site. This is a strategy followed by many having continuously updating content. But as new features get added to the traditional website the mobile site tends to get left behind forcing the user to click full site option on his/her mobile, thus defeating the concept of having a separate mobile site.

Moreover an app provides a better viewer experience for scanning the same content on a mobile, rather than viewing it on an abridged site. At least I think so. And this motivated me to give a shot at developing this mobile application.

Putting all these aside isn’t it cool to have our own mobile application?

I choose to develop app on windows phone as it is having pretty good development tools and moreover I am comfortable in working with Visual studio. If I get good response I will give a try on Android too.

Emulator screenshots

Before proceeding into internals let's visualize how this app looks like on emulator (the same is provided as an attachment for download).

Fig 1: The application screen


Fig 2: Codeproject Home in portrait mode


Fig 3: Codeproject Home in landscape mode


Fig 4: Fetched latest MFC/C++ content in portrait mode


Fig 5: Fetched latest MFC/C++ content in landscape mode


Fig 6: Article view in portrait mode


Aren't these images great. Hope by now you all are convinced that it is really cool to have an app like this.

Organization of the code and pages

Now let's see how the pages are organized and connected.

The MainPage.xaml holds the UI to populate the home screen of the app (as shown in fig.2). If you parse this xaml you may be wondering why each button is wrapped with a border. This border is actually required to make the button corners round. As there is no way to set corner radius to a button I used a border and set it's CornerRadius property to get the feel of a round button.

The button clicks are handled in the code and depending on the button we will fetch the appropriate RSS from the _RSSFeed array

// string array to hold RSS feeds url
string[] _RSSFeed = { 
  "", // All latest content
  "", // MFC/C++ latest content
  "", // C# latest content
  "", // VB latest content
  "", // ASP latest content
  "", // Mobile latest content
  "" // Lounge latest content

Utilizing NavigationService.Navigate method we will then navigate to ArticleView.xaml and this fetched RSS url is passed to ArticleView.xaml as an value with the key 'RSSFeed'

NavigationService.Navigate(new Uri("/views/ArticleView.xaml?RSSFeed=" + 
                             _RSSFeed[(int)RSSCategory.AllArticlesRSS], UriKind.Relative));

In the OnNavigatedTo event of ArticleView this value is retrived back.

protected override void OnNavigatedTo(NavigationEventArgs e)
    string strTemp;
    NavigationContext.QueryString.TryGetValue("RSSFeed", out strTemp);
    // ......
    // ......

This RSS feed url is parsed by utilizing helper class RssService and the data is stored in RssItem class. Further this is made as item source to the list box so get the wonderful view as shown in fig.4 and 5.

Details regarding RSS feeds and a way to parse them is better explained in the article 'Reading RSS items on Windows Phone 7'. I do not want to bore the readers by duplicating all that information. One can always refer to this nice article.

protected override void OnNavigatedTo(NavigationEventArgs e)
   // .....
   // .....

   // Fetch the RSS items using the helper and set this to the listbox controls
                             (items) => { listbox.ItemsSource = items; },
                             (exception) => { MessageBox.Show(exception.Message); }, null );

If you see in the ArticleView.xaml, this listbox is made up of a hyperlink button and two text blocks which are binded to Tittle, PublishedDate and PlainSummary respectively.

Now when some one clicks the hyperlink button the respective page will be navigated automatically in the browser. But say if any user clicks another link in this web page and then if he wants to come back to the first page he can not do by clicking the phone's hardware back button (this will take him to the ArticleView.xaml page but not to the first page).
This is very much annoying and after much searching I decided to have a new xaml page with a browser control. The back and forward operations are handled in this page to give nice user experience. All the visited web pages are stored in a list named URLHistoryStack to facilitate circling around them.

At the initial click of the hyperlink the respective url is passed to Browser.xaml (which is having a browser control webBrowser1) as value with 'SelectedArticle' as key and in OnNavigatedTo event of this page the url is retrieved and set to webBrowser1.

protected override void OnNavigatedTo(NavigationEventArgs e)
   string uri = "";
   if (NavigationContext.QueryString.TryGetValue("SelectedArticle", out uri))
      webBrowser1.Navigate(new Uri(uri, UriKind.Absolute)); // set the intial click url

When the user navigates to webBrowser1 of Browser.xaml initially by clicking the ArticleView listbox's hyperlink button then we have to clear all the old history and add this a fresh.

private void webBrowser1_Navigated(object sender,
                                   System.Windows.Navigation.NavigationEventArgs e)
   if (this.webBrowser1.Source != null && !this.IsNavigationButtonClicked)
     if (PositionIndex == 0)
        // This is the first page, so clear the old history if any and add this a fresh
        string firstURL = this.URLHistoryStack[0];
     // Add this url to the history and increment the index
  this.IsNavigationButtonClicked = false;

To facilitate the movement between web pages in the way I described, two new buttons are added and their click is handled to update the history stack

// Handling back button click
private void Button_Click_Backward(object sender, RoutedEventArgs e)
   if (PositionIndex <= 0)
     // He came to the first page and may be wants to go back to ArticleView
     NavigationService.Navigate(new Uri("/views/ArticleView.xaml", UriKind.Relative));
     // Add this url to the history and decrement the index
     this.IsNavigationButtonClicked = true;
     this.webBrowser1.Navigate(new Uri(this.URLHistoryStack[PositionIndex - 1].

// Handling forward button click
private void Button_Click_Forward(object sender, RoutedEventArgs e)
   if (this.URLHistoryStack.Count > PositionIndex + 1)
     // Add this url to the history and increment the index
     this.IsNavigationButtonClicked = true;
     this.webBrowser1.Navigate(new Uri(this.URLHistoryStack[PositionIndex + 1]

Another set of buttons are provided in this page to go back to the Article view or to the home page.Now when an user comes back to Articleview page we will not have the original RSS feed used to populate this page. So to handle this the RSS feed is stored as application state data.

 PhoneApplicationService.Current.State["RSSFeed"] = strTemp;

// Note how the RSS data is stored as application data with RSSFeed as key.   

Epilog and Points of Interest

As I am just crawling in to the world of Windows phone development, I neither have the experience or expertise to develop a professional mobile app. I know that the application is naive, but makes the reader familiar with few concepts like accessing RSS feed in Windows Phone, using the application state data, creating image buttons, making buttons round etc.

I want to do many more things in this application like:

1. Let the user customize/pick the RSS feeds he wants to monitor.

2. Provide him the option to login into his account (currently I don't know how to achieve this in app).

3. Make controls properly align in Landscape mode and improve their look and feel.

4. Allow the users to bookmark items and pop up alert when these are updated (in a proper way, else we may be consuming phone resources too much and the users may not appreciate it).

And many more. I feel that to do few things (like providing login support) we need data/help from the CP site - Hope Chris Maunder (CP site Admin) & Sean (CP site content Manager) are interested in providing them.

I would like interested amateurs to make appropriate changes for better viewer experience.

Thanks for peeking through this article and hope that you would appreciate this little effort of mine.

External References




Thanks to Sifayideen for his help in creating the XAML files.


1st February 2012: Added this article
20th February 2012: Added xap file for download


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Lakamraju Raghuram
Technical Lead
India India

Did my masters from IIT-M in Advanced Manufacturing Technology and working mainly on C++ in CAD domain from 2004 onwards.
Working on web technologies using Angular 7.0 and above, HTML5, CSS3 from 2015.

Comments and Discussions

GeneralMy vote of 5 Pin
Amol_B29-May-13 18:36
professionalAmol_B29-May-13 18:36 
QuestionWell done Pin
Eholland2213-Sep-12 23:05
MemberEholland2213-Sep-12 23:05 
QuestionNot a Metro! Pin
Siavash Mortazavi2-Apr-12 13:00
MemberSiavash Mortazavi2-Apr-12 13:00 
AnswerRe: Not a Metro! Pin
Lakamraju Raghuram2-Apr-12 16:22
MemberLakamraju Raghuram2-Apr-12 16:22 
GeneralRe: Not a Metro! Pin
Siavash Mortazavi3-Apr-12 4:02
MemberSiavash Mortazavi3-Apr-12 4:02 
GeneralMy vote of 5 Pin
vijay patel 22-Apr-12 3:22
Membervijay patel 22-Apr-12 3:22 
GeneralRe: My vote of 5 Pin
Lakamraju Raghuram2-Apr-12 3:28
MemberLakamraju Raghuram2-Apr-12 3:28 
GeneralMy vote of 5 Pin
Dan Thyer19-Mar-12 14:42
MemberDan Thyer19-Mar-12 14:42 
GeneralRe: My vote of 5 Pin
Lakamraju Raghuram20-Mar-12 16:39
MemberLakamraju Raghuram20-Mar-12 16:39 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey28-Feb-12 18:04
professionalManoj Kumar Choubey28-Feb-12 18:04 
GeneralRe: My vote of 5 Pin
Lakamraju Raghuram2-Mar-12 7:12
MemberLakamraju Raghuram2-Mar-12 7:12 
Questionwhat do i need to install in vs2010 to start windows development? Pin
Mico Perez8-Feb-12 21:07
MemberMico Perez8-Feb-12 21:07 
AnswerRe: what do i need to install in vs2010 to start windows development? Pin
Lakamraju Raghuram8-Feb-12 22:05
MemberLakamraju Raghuram8-Feb-12 22:05 
QuestionHi Pin
SasiKumarC31-Jan-12 22:19
MemberSasiKumarC31-Jan-12 22:19 
GeneralRe: Hi Pin
Lakamraju Raghuram31-Jan-12 22:31
MemberLakamraju Raghuram31-Jan-12 22:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.