by Laurent Bugnion via Silverlight on 6/14/2009 10:17:28 PM
To make development of WPF and Silverlight applications according to the Model-View-ViewModel pattern easier, I have put together a small toolkit which should speed up the creation of such applications by automating certain tasks.
The toolkit must be installed manually for now. My next task is to prepare an installer, which should allow installing everything automatically, and also checking for upgrades, upgrading automatically and uninstalling the toolkit. For now however, a little manual work must be done.
This article refers to the WPF version of the MVVM light toolkit. In the next few days I will post the Silverlight version.
Update: The Silverlight version has been published.
My next priority is to create an installer which will automate the installation process.
I also want to create and write about a few sample applications related to the toolkit. There is a lot to be said and demoed about MVVM in general, and this toolkit in particular. I am impatient and curious to see what direction future development will take. I have a few ideas I would like to add to the toolkit, more about that later.
I am as always very interested in feedback, so do not hesitate to post a comment here, or contact me to start a discussion.
To be completely honest, I do not intend to add a lot of features to the toolkit. First, I am intrigued by new developments in Expression Blend 3 that I will keep under scrutiny, to see how they influence (or make obsolete) some of the features of this toolkit. Also, WPF 4 and Silverlight 3 will change the game of MVVM by (hopefully) integrating some of the concepts into the framework and making it an even more natural fit.
HOWEVER let’s keep the discussion rolling, so you know what to do if you like, dislike or want to change something in the toolkit ;)
The community and Microsoft already have a few MVVM initiatives running. However, I didn’t find any completely satisfying for my particular set of requirements. Most importantly, I work as an integrator in WPF and Silverlight projects, and I use Expression Blend a lot. My toolkit is finely tuned to make working in Expression Blend much easier, for designers and developers. For instance, it allows creating design time data very easily, in order to facilitate design work. To be honest, I have been using some of the classes and concepts gathered here for quite some time already, but this is the first time that I have a clean, complete kit of features related to MVVM.
I spent a lot of time making the syntax and the features in the toolkit as compatible as possible between WPF and Silverlight. Most of the code can be shared between WPF and Silverlight. Minor changes are needed in XAML, but the ViewModels are compatible (as long as you don’t use WPF-only or Silverlight-only features of course).
Also included in the toolkit, you will find a Messenger making it super easy to enable communication between classes. Using the Messenger class and the classes in the GalaSoft.MvvmLight.Messaging namespace, you can broadcast messages to instances who registered for a particular type of message without worrying about dependencies or memory leaks.
Since it is a “light” toolkit, it should be quite easy for you to modify it to suit your own needs. Do not hesitate to inspire yourself from this code, or to modify it at will.
To install the toolkit manually, please follow the steps.
The instructions for Silverlight are posted in another blog post.
Note: The application is localized in French for demo purposes. This can easily be changed in the code.
If you need a new ViewModel in the MVVM application, follow the steps:
Of course you also need to initialize your ViewModel by entering code in the constructor.
Of course a ViewModel is tightly associated to a View. After adding a ViewModel, you probably want to add a new View too. In the WPF version of the application, a new View is a new Window. If you need a more finely granulated user interface, you can link the ViewModel to a UserControl instead, or even to other UI elements. This scenario is not supported by the toolkit, however, and requires some manual work.
To add a new Window-based view in the application, follow the steps:
Finally, you probably want to add bindable properties in your ViewModel. Follow the steps:
Original Post: MVVM light toolkit for WPF and Silverlight
The content of the postings is owned by the respective author. Silverlight Feeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on Silverlight Feeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.