The Windows Presentation Framework (WPF), Silverlight, and Windows Phone 7 are the latest technologies
for building flexible user interfaces (UI) for applications built with Microsoft technology.
All three rely on the XAML markup language to describe UI elements and layout, and you can program
applications for all three platforms with the most common of Microsoft .NET Framework languages:
Visual C# or Visual Basic .NET. If you are a .NET developer planning to create a new Line of
Business (LOB) application using the .NET Framework, you should consider adopting one of these
technologies as your UI technology. At the same time, as you start planning to build an application
based on one of these technologies, you should also seriously consider learning and applying
the Model View ViewModel (MVVM) presentation pattern, a design pattern created specifically for
these technologies.
And that’s what this book is about. You might be wondering, “Why another book on WPF?” Or,
if you have already looked at the Table of Contents, you might be thinking, “Why another book
about layering and design patterns?”
To answer those questions, let me start by saying that over the years, I have noticed that
what developers ask for the most is not the “Bible of patterns” or the “Bible of how to layer
an application;” instead, they want a simple, straightforward book that guides them through the
development criteria for a real-world, yet simple, application that uses and explains patterns—but
that is also reusable in future projects as a “template” for other applications.
WPF and Silverlight are young technologies, and the percentage of developers moving to this new
way of designing the UI is still small. There are several reasons for this. First, the learning curve is
relatively high. If you’re used to Windows Forms, Java Swing, or Delphi, the way you design and
structure an application using XAML and WPF is significantly different—in fact, I would call it
“revolutionary.”
In the past, I have used well-known patterns to build applications, including the Model View Presenter
pattern with Windows Forms applications, and the Model View Controller pattern with ASP.
NET applications. But with WPF, these two approaches are now obsolete, because they can’t take
advantage of the powerful engine provided by XAML. Of course, you can still take advantage of
the binding engine of WPF using the Model View Presenter pattern, but the effort required is usually
too large. Fortunately, MVVM provides an alternative.
Microsoft, in collaboration with some architects, has revised the original Presentation Model that
was proposed years ago by Martin Fowler. This revision (named the Model View ViewModel pattern)
is the perfect approach for WPF and Silverlight because, well, it was designed specifically
for them! Unfortunately, like XAML, MVVM is a relatively new technology, so at the moment,
there isn’t a lot of information about implementing it. There are a few bloggers trying the MVVM
approach and blogging about it; others are involved in building MVVM-specific toolkits. But nearly
everything is still experimental, and there are few truly concrete examples.