how do i do… With the Model-View-ViewModel pattern
While building the Composite Application Guidance for WPF and Silverlight (AKA Prism V2), we relied heavily on the Model View ViewModel pattern. But while this pattern is definitely the best thing ever, it took me a while to come to grips with it:
First of all, I have a mostly Windows Forms and ASP.Net background. With these technologies, I typically applied different separated presentation patterns, such as Model View Presenter. So when I tried to build WPF and Silverlight applications, I tried to apply the same techniques. But what I found was, that building WPF and Silverlight applications is significantly different from those other technologies. When I tried to apply the Model View ViewModel pattern, I kept running into questions. How do I do “X” in this pattern.
At first glance, the Model View ViewModel does not differ that much from other separated patterns such as Model View Presenter. It certainly tries to achieve similar goals, but it does it in subtly different ways.
In this series of blog posts, I’m going to describe how to apply the Model View ViewModel pattern and what kind of challenges you’ll have to overcome and what kind of decisions you’ll have to make. Over the next couple of weeks, I’m going to be writing about these topics:
How do I:
(Inside the MVVM pattern)
- Describe the differences between the MVVM pattern and other separated presentation patterns
- Implement the Model View ViewModel pattern
- Adapt a simple vs complex model to the View
- Work with popups and modal dialogs
- Trigger animations from the View (without code behind)
- Avoid code behind while building Views
- Work with asynchronous methods
(When applying the MVVM pattern to an application)
- Instantiate my Views / ViewModels
- Create a logical ViewModel structure of my application
- Implement automatic datatemplate selection in Silverlight
Hope you’ll find these topics interesting. If there are specific things you are struggling with, let me know. If i have time, I’ll try to write something about that as well.
Note, you’ll need to download the following references:
As I’m publishing new blog posts, I’ll keep updating this app, so check back sometimes for updated versions..
Comments
Anonymous
August 11, 2009
Hi Erwin All topics are interesting, it will be the usefull reading. Is there any way to apply MVVM with MEF? Thanks. Sorry for english.Anonymous
August 14, 2009
This is a great idea for a blog series. I, myself, come from a winforms background (mostly MVP) and am struggling with MVVM. Looking forward to the posts!Anonymous
August 15, 2009
Good point! MVVM with MEF.. I'll try to address that when I discuss instantiating views/viewmodels. Keep posted ;) Thanks, _ErwinAnonymous
December 02, 2009
The comment has been removed