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:
- The application to be converted was already stable – a good data model is already in place and ready for consumption.
- 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:
- 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.
- 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.
- 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.
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: