One of the questions we frequently get when meeting with customers is whether or not to adopt WPF over WinForms, Win32 or some other technology. As much as I’d love to have the answer always be “of course!”, the reality is that it depends on a number of factors that need to be taken in consideration.
This technical article by Peter Faraday and Brad Becker outlines well some of the benefits and tradeoffs. In addition, I would consider the following:
- Length of Project: Although we’ve tried to make WPF easy to use, as with any new technology there is a learning curve, which can be problematic if the schedule doesn’t leave much room for it or if you can’t afford to train developers to use WPF.
- Project Lifespan: Are you planning on using this project, and its associated technology, for an indefinite period of time? Or is the project near it’s end of life, only requiring an incremental improvement?
- Goals of Project: Are you planning on providing an improved user experience for your application, or are you planning on extending existing functionality provided by your custom control? You could decide to use WPF for the application chrome, yet continue using the existing technology for custom components that would be too expensive to re-write.
- Scope of WPF Use: Using some of the interop features of WPF, it’s possible to make use of other technologies in conjunction with WPF. For example, you can use WinForms in WPF (WinFormsHost), WPF in WinForms (ElementHost), Win32 in WPF (HWndHost) or WPF in Win32 (HwndSource).
- 3rd Party Components: The application might depend on components that can’t be updated, in which case it might not be as easy to transition to WPF.
In addition, a few additional points have come up:
- High DPI: WPF applications are DPI aware, meaning WPF is resolution independent and will scale if DPI settings are changed. This blog entry describes this in good detail.
- System Fonts: This is particularly important for companies that rely on system fonts to provide a consistent experience, as well as companies that have accessibility requirements such as High Contrast. WPF does use system font settings for the default theme, that is unless you override these settings by using a custom style/skin/theme that does not make use of system fonts.
- Accessibility: WPF has support for the latest UI automation technology (UIA), which works well with the screen reader and magnifier included with the OS. Although UIA does have backwards compatibility with its predecessor (MSAA), many 3rd party screen readers and magnifiers are still MSAA based and don’t directly support UIA at this particular time, but some have indicated they are working on adding UIA support going forward.
- Globalization/Localization: This is possible using WPF. Rob Relyea posted this blog entry on the topic.