Converting a Web Application (BusterNews.com) to a WPF Desktop Application

I wrote BusterNews.com in 2004 as a personal exercise in ASP .Net. The application has served me very well through the years as my online RSS reader. I recently found myself writing a counterpart of the reader in WPF.

I have been contemplating to convert BusterNews.com into a rich Internet application (RIA) since the first beta of Silverlight came out a long time ago. I have never been able to do it due to the limits of time and technology. However, for most week nights the past week and a half, the stars aligned for me to come up with a decent WPF version of the reader part of the application. Although it is not an RIA, I should be able to easily convert this version into a XAML Browser Application (XBAP), then, eventually, into a Silverlight application.

I think being able to come up with this application in a relatively short period of time was due mostly to the following:

  1. The application to be converted was already stable – a good data model is already in place and ready for consumption.
  2. I am now more familiar with the tools and technologies to be used to meet my objective.

Technical Implementation

On the back-end, the SQL Server database is unchanged. However, I wrote ASP.Net web services to provide the inter-op services between the WPF application and the database. The Entity Framework and LINQ provided means to rapidly implement these. My current version is noticeably slower (but acceptable) in performance than the original because it does not (yet) use stored procedures.

On the front-end, WPF provides the technology to come up with a rich, interactive application. Although I haven’t taken advantage of many of WPF’s UI features such as animation, effects, etc., the GUI that I came up with is significantly more useful than the web version (e.g., using the FlowDocumentReader control, I provide instant features for searching content and changing a document’s view). WPF’s powerful data binding features also provide the services I need to easily present the same data in many places, in different ways. In addition to this, a crucial component of the application is the Xceed DataGrid for WPF which provides data virtualization (a topic for a separate blog entry) --- while BusterNews.com provides a view of the data in pages, the WPF version, despite having a web service as a data source, is able to provide virtually a full view of the data without much negative impact on performance.

The application is deployed as published ClickOnce application so I get the benefits of being able to install the application from the web, as well as the online update features of ClickOnce applications to easily upgrade to new versions (this was very useful in testing, to update my test installations as I found bugs). Deploying the application is as easy as using the ‘Publish’ option from Visual Studio 2008 and specifying the publishing information.

Challenges

I encountered some challenges in coming up with this application, probably mostly due to lack of planning; I have had this project at the back of my mind for a long time and then it ‘just happened.’ Some of the real technical challenges I encountered were:

  1. Designing the web services – I initially planned to keep the web services stateless. However, I ended up using session state as it plays a major role in my implementation of data virtualization. I struggled with making this decision for a relatively long time but I think I made the right one.
  2. Converting HTML to XAML – RSS feeds for blogs are usually formatted in HTML. In a web application, it does not take much effort to display HTML. In a WPF application, however, presenting HTML is not as easy. Although there is a web browser control that could host the HTML, the control is just a wrapper to the IE browser control and does not play well with WPF in terms of presentation, just like Windows Forms controls. The solution was to find a way to convert HTML to XAML. This took a lot of effort. I found two top contenders for my implementation – XAML/HTML Converter and SgmlReader. I ended up using XAML/HTML Converter, modifying the code slightly to fit my requirements, including support for images; this is still a work in progress but I can live with the current version that I have.
  3. Presenting data – As I mentioned above, BusterNews.com presents a view of data in pages, as is common in web applications. I wanted to overcome this limitation in my WPF application. The challenge was that the data source for the application is a web service and I wanted the application to perform as if the application had a direct connection to the data and show the data in a contiguous list rather than in pages. The Xceed DataGrid for WPF (Professional Edition) solves this problem for me by providing data virtualization (I will talk about this in a separate blog entry). The result is a responsive application that requests just the right amount of data from the web service (if it is not already in memory) as is needed by the current view of the user.

The result

Following are screen shots of BusterNews.com and its WPF counterpart, BusterNews Reader, respectively.

BusterNews.com

BusterNews Reader 

This has been an exciting exercise for me, to make the old new again. My next step is to convert the WPF application into an XBAP to make it more web-friendly; hopefully within the next few weeks.

Links:

Technorati Tags:

posted @ Sunday, March 01, 2009 9:32 PM

Print

Comments on this entry:

# re: Converting a Web Application (BusterNews.com) to a WPF Desktop Application

Left by Naveen Lakamsany at 3/16/2009 10:46 PM
Gravatar
Hi. Your article is really good. I have a question for you. I have got a project and they want me to convert web based to windows based application. They asked me whether I can use any software like xaml/html converter for doing it quickly or should I do it from the scratch. Can you tell me which one do I select and if the answer is xaml/html converter, how much time will it take and how much can I depend on the converter. I f i use the converter, will everything be done or should I again write code or modify code manually?

# re: Converting a Web Application (BusterNews.com) to a WPF Desktop Application

Left by AlanO at 3/17/2009 9:36 AM
Gravatar
Naveen,

I highly recommend looking at XAML/HTML Converter if you haven't started coding your own converter yet.

I found the XAML/HTML Converter project very well structured in terms of logic and it gave me a lot of insight in the way a parser for this purpose could be built. The code is written well all-around, in my opinion, for me to be able to follow the intention behind the code.

You will most likely have to modify the code for your purposes if you decide to go with XAML/HTML Converter.

I think it is worth considering even if you decide not to go with it, if only to learn the technique it uses for the task.

Thanks.

Alan

# re: Converting a Web Application (BusterNews.com) to a WPF Desktop Application

Left by Jay at 4/3/2009 1:22 PM
Gravatar
Are you willing to share the changes for image support?

# re: Converting a Web Application (BusterNews.com) to a WPF Desktop Application

Left by Tushar at 12/22/2009 1:02 AM
Gravatar
Can you share your changes for the image support?

Your comment:



 (will not be displayed)


 
 
 
Please add 4 and 2 and type the answer here:
 

Live Comment Preview:

 
«March»
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910