The WPF team released an early version of the MVVM Toolkit as part of the WPF Futures project in CodePlex.
I just fired up a test project. The download includes an application wizard that provides a barebones application with Commands, Models, ViewModels and Views solution folders. The app wizard also asks to create a test project (like ASP.NET MVC). The source code support is included in the solution, with a ViewModel ‘base’ class providing basic INotifyPropertyChanged support.
All looks pretty good for a first step. Here’s what I’d like to see in the future:
- The code walkthrough seems to follow the pattern of complete ViewModel abstraction. This means that the ViewModel class re-exposes all properties from the underlying model. I’m more pragmatic on this one, and prefer to have ViewModels that expose the underlying model type and only expose properties that project view specific data (like converter functions). It would be great to see a ViewModel base class with support for property changed propagation (from model to view).
- There doesn’t seem to be any support for ViewModel collections. When you create a ViewModel you essentially have to maintain a ViewModel tree in parallel to the Model. This is easy enough for static models, where a collection never changes; but if the data is dynamic then the ViewModel tree needs to stay in sync with the model. There are a couple of solutions to this: - one is to have a ViewModel collection class that listens to the underlying model’s CollectionChanged notifications; another solution is to use something like CLINQ. This provides complete collection projection to a ViewModel class wrapped around a model using a LINQ query.
- Lastly, it would be great to see better designer support for ViewModels. For example, what about generating the ViewModel property stubs based on the binding elements in a View? In fact, most of the work the ViewModel does could be handled by a dynamic shim based on the View’s binding directives. This would greatly reduce the labor intensive task of manually synchronizing of ViewModels to Models.
Just a few thoughts. It would be great to see this in VS2010.