Better User and Developer Experiences – From Windows Forms to WPF with MVVM: Introduction
I frequently talk to people trying to decide, for a new project, between Windows Forms and Windows Presentation Foundation. After spending time with WPF, I feel there is no reason to choose Windows Forms for new development. WPF, when used correctly, is far superior, both in terms of user experience, but also developer productivity.
I feel that the confusion around choosing WPF really stems from a lack of understanding about WPF. Even people on my own team have been overwhelmed trying to understand how the different pieces of WPF fit together, and how to apply the new concepts introduced with WPF effectively. In order to address this, I’m going to break this down into a few simple pieces, and show the migration in terms of thought required to transition from being a good Windows Forms developer to an effective WPF developer.
Windows Presentation Foundation is huge. Do not doubt it. It is huge, both in terms of scope, but also in terms of the radically different approach it takes to developing user interfaces than other technologies. Don’t let the scope frighten you, however – it is very well thought out, and very usable, once you understand some of the basic concepts.
In addition to the huge scope of WPF, new design patterns have evolved to take advantage of the new features introduced by this framework. The most commonly referenced one, in terms of WPF, seems to be MVVM, or Model-View-ViewModel. The Model-View-ViewModel pattern was inspired by some of the features in WPF, and seems perfectly fit for WPF, so many developers advocate it (with good reason) for use with WPF.
Again, don’t let this frighten or discourage you… MVVM isn’t about making WPF more difficult, it’s about making WPF usable in a quick, efficient manner. Learning MVVM actually makes understanding WPF easier, not more difficult.
The issue here is that WPF is large, and the framework doesn’t force you into a single way of working. There are lots of ways to work with WPF, including doing nearly the exact thing you’re used to with Windows Forms! This is part of the power and flexibility of WPF, but also a trap to watch for and to avoid. MVVM helps guide and force you to take advantage of WPF’s new features effectively, insulating you from common pitfalls and mistakes.
For this series, I’m going to start by showing a simple Windows Forms application – an RSS Feed Reader, and demonstrate converting it to WPF. I’ll start with a strait conversion – and demonstrate how you can make WPF look and work exactly the same as you can with Windows Forms. I’ll then explain, in details, some of the new ways of thinking that are pervasive within WPF, and show how this should change your way of thinking about user interfaces.
In order to do this, we’ll work with four separate projects – which include three completely different versions of the same application. The goal here isn’t to use WPF to make the application “pretty†or “flashyâ€, rather, it’s to show how you can use WPF to make an application more developer friendly, including making it cleaner, more logical, easier to maintain, and more testable.
I’m really looking forward to read these series of posts 🙂
Hey Reed, great series of posts. I was wondering if you had the source code for these applications that I could download. If so could you point me in the right direction? TIA
David S:
The source code is all available here: http://code.msdn.microsoft.com/WinFormToWPFMVVM
It’s linked from the conclusion and summary pages, as well.
-Reed
Thanks. I read it to the end just now. Excellent series for anyone who is moving from Windows form to WPF!!
The link to the code no longer works. Is it somewhere else I can download it? Much appreciated.
The code is available at the bottom of the main page: http://reedcopsey.com/series/windows-forms-to-mvvm/
After having some pretty negative experiences with poor tutorials that simply give directions, paragraph 2 was certainly encouraging
Well, I hope it helps. Let me know if you have any questions.