Adopting Windows Presentation Foundation (WPF)

INTRODUCTION:
Last year Microsoft released Windows Presentation Foundation (WPF), a new platform for building rich user experiences on Windows. Microsoft has also announced that Windows Forms, widely utilized for traditional “forms over data” applications today, will continue to be supported for years to come. An obvious question then, is which technology to choose for new applications and when organizations developing Windows Forms applications should adopt WPF. The answers depend on a number of variables that we’ll explore below.

THE MULTIPLATFORM ADVANTAGE:
The first thing to keep in mind is that the platforms are not mutually exclusive. WPF and Windows Forms can both be used in a single application since each technology is capable of hosting user interface elements defined by the other. The two platforms have different strengths and can complement each other. For example, Windows Forms provides many useful LOB controls, while WPF uniquely offers things such as 3D graphics and animations.

Current Windows Forms-based projects can start using the benefits of WPF gradually and incrementally. Windows Forms and WPF interoperability make it easy to extend existing projects. Some early adopters have piloted this by building a new WPF visualization or component for their existing application using the interoperability layer.

Similarly, WPF can also be used in concert with MFC or Win32. WPF controls can be hosted within existing Win32/MFC code, and existing Win32/MFC controls can be hosted within WPF. Microsoft Expression Design is an example of a project that mixed Win32 code with WPF to provide an improved user experience without rewriting the entire application. This is a real world example of how using WPF doesn’t require throwing away all of an application’s existing code.

THE BENEFITS OF WINDOWS FORMS

Window Forms is a mature "forms over data" technology. It has an extensive ecosystem of controls, developers, and vendors that has evolved over the last twenty years of development based on the GDI/GDI32/GDI+ platform. These are good reasons to continue using Windows Forms.

There are also some features that are unique to this platform. Windows Forms has a wide range of controls for presenting tabular data, for working with system dialogs, for graphics metafiles, and for date, time and calendar support. The richest design surface in Visual Studio is for Windows Forms, allowing rapid construction of an LOB application. It provides extensive support to quickly build databound applications and to connect to remote data sources.
Microsoft has announced the continued support of Windows Forms so if you have an existing Windows Forms application you can feel secure in a good level of support for your existing code base. Developers with years of experience with Windows Forms can continue to be productive working in a technology they are familiar with. If you need to deploy on older PCs running versions of Windows prior to XP SP2, Windows Forms will work well under these conditions.

If you are building a traditional forms-based application, have existing expertise in Windows Forms, and are satisfied with current tools and components then Windows Forms continues to be a good fit. It leverages Microsoft’s ongoing investment in .NET (such as LINQ and the Dynamic Language Runtime) and provides a robust set of controls and best of breed IDE and forms designer in Visual Studio. Since Microsoft will support Windows Forms for many years, the main reason to look at Windows Presentation Foundations is if you’re ready to take advantage of its unique features.

BENEFITS OF WINDOWS PRESENTATION FOUNDATION

Windows Presentation Foundation was created to allow developers to easily build the types of rich applications that were difficult or impossible to build in Windows Forms, the type that required a range of other technologies which were often hard to integrate.

WPF is the platform of choice for today’s visually demanding applications with its inherent support of rich media, data visualization, complex text content, dynamic interactive experiences, and branded or custom look and feel. For these types of applications, WPF provides significant advancements in areas such as advanced layout, control skinning and styling, animated hardware accelerated 2D and 3D graphics, and built in support for rendering of rich documents.

Since the platform is new, so is the tooling. Visual Studio 2008 has core WPF support with a new design surface that provides drag and drop support for WPF layout and controls, a new property editor, as well as Intellisense support for XAML editing. Moving forward, Microsoft is committed to extending the support for WPF even further in the next version of Visual Studio. The type of richer applications that WPF enables generally requires the participation of new team members: visual and interaction designers. Because of this, Microsoft has introduced a new tool for these roles—Microsoft Expression Blend. This product focuses on the more creative, visual, and interactive aspects of the platform by exposing WYSIWYG ways to manipulate animation, skinning and styling, databinding, and general visual asset creation. To help integrate these team members, Expression Blend supports Visual Studio projects.

A less obvious advantage to WPF is the improved development experience with its declarative markup language (XAML) that can be used for bulk of many applications. WPF makes it easier to follow the model-view-presenter pattern and reduces the amount of code in your presenter using templates. The benefits of XAML are not just in the presentation, databinding allows declarative connection to the underlying model. All of this makes it much easier to change your user interface without needing to change the other layers of your application. Another important aspect of XAML is the ability through these file formats to have designers and developers able to work on the same files .
A last advantage worth mentioning is that Silverlight will maintain a high level of compatibility with WPF so investments in WPF allow for easy porting and sharing between Web and Windows client applications. If you are considering the need to deploy to other platforms then you will be able to make use of Silverlight with almost the same code as WPF.

Going forward, Windows Presentation Foundation will be Microsoft’s solution for most types of applications including standard forms-based applications. WPF is a foundation which goes beyond traditional platforms and other user interface toolkits. The potential with the WPF platform is to build applications that set a new bar for sophistication, usability and user experience.

CONCLUSION:

>> If you have an existing Windows Forms application or are building a traditional forms-based application and are looking for a mature technology to use with mature tools and component support then Windows Forms is a good fit.

>> If you have an existing Windows Forms (or MFC/Win32) application that could benefit from some of the advanced presentation features of WPF, you can add WPF to your existing project.

>> If you’re wanting to create a new experience for your users that is rich, interactive, sophisticated, or highly custom or branded, WPF is Microsoft’s next-generation platform for your project today.

>> If you’re targeting the web, Silverlight shares the same development model as WPF but is optimized for a lightweight, cross-platform runtime. Investing in either WPF or Silverlight nets you the skills, tools, and assets for both platforms.