Introduction
The main purpose of the toolkit is to accelerate the creation and development of
MVVM applications in WPF, Silverlight and in the Windows Phone.
Like other MVVM implementations, the toolkit helps you to separate your View
from your Model which creates applications that are cleaner and easier
to maintain and extend. It also creates testable applications
and allows you to have a much thinner user interface layer (which is more difficult
to test automatically).
This toolkit puts a special emphasis on the "blendability"
of the created application (i.e. the ability to open and edit the user interface
into Expression Blend), including the creation of design-time data
to enable the Blend users to "see something" when they work with data
controls.
Much has been written about MVVM as a pattern. I recommend starting with the following:
Installation and Creation
The MVVM Light Toolkit installation procedure is described
here.
To create a new MVVM Light application, check this article
(for Visual Studio) and this one (for Expression
Blend).
Components
This toolkit gathers libraries and helper components for Windows Presentation
Foundation, Silverlight and for Windows Phone 7.:
- The GalaSoft.MvvmLight library with helper classes:
- A ViewModelBase class to be used as the base class for ViewModels.
- A Messenger class (and diverse message types) to be used
to communicate within the application. Recipients only receive the message types
that they register for. Additionally, a target type can be specified, in which case
the message will only be transmitted if the recipient's type matches the target
parameter.
Messages can be anything from simple values to complex objects.
You can also use specialized message types, or create your own types deriving from
them.
More information about the Messenger class.
- MessageBase: A simple message class, carrying optional information about
the message's sender.
- GenericMessage<T>: A simple message with a Content property of type
T.
- NotificationMessage: Used to send a notification (as a string) to a recipient.
For example, save your notifications as constant in a Notifications class, and then
send Notifications.Save to a recipient.
- NotificationMessage<T>: Same as above, but with a generic Content
property. Can be used to pass a parameter to the recipient together with the notification.
- NotificationMessageAction: Sends a notification to a recipient and allows
the recipient to call the sender back.
- NotificationMessageAction<T>: Sends a notification to a recipient
and allows the recipient to call the sender back with a generic parameter.
- DialogMessage: Used to request that a recipient (typically a View) displays
a dialog, and passes the result back to the caller (using a callback). The recipient
can choose how to display the dialog, either with a standard MessageBox, with a
custom popup, etc…
- PropertyChangedMessage<T>: Used to broadcast that a property changed
in the sender. Fulfills the same purpose than the PropertyChanged event, but in
a less tight way.
- Command classes optimized for WPF and Silverlight and simplifying commanding in
your application. Available with or without generic parameter (RelayCommand<T>
and RelayCommand). For an in-depth analysis, I encourage
you to read
Using RelayCommands in Silverlight and WPF
- The GalaSoft.MvvmLight.Extras library with optional classes:
- EventToCommand behavior, allowing you to bind any event of any
UI element to an ICommand, for example on the ViewModel, directly in XAML. This
makes using Commands much easier, without writing code behind. With the newest version,
you can even get the EventArgs of the fired event directly in the ViewModel to handle
it.
- DispatcherHelper class, a lightweight class helping you to create
multithreaded applications.
- Project Templates for WPF and Silverlight applications,
installed in Visual Studio and in Expression Blend. Use File, New
Project, Windows, Mvvm, MvvmLight to create a new fully functional MVVM application
that you can extend.
For Silverlight, choose File, New Project, Silverlight, Mvvm, MvvmLight.
- Item templates for WPF and Silverlight applications, to
easily create new items in Visual Studio and in Expression Blend:
- Create a new ViewModel.
- Create a new View.
- Create a new ViewModelLocator, a class that holds
and manages references to ViewModels.
- Code snippets to speed up the addition of new properties (Visual Studio
only):
- mvvminpc adds a new bindable property to a ViewModel.
- mvvmlocatorproperty adds a new ViewModel to a ViewModeLocator.
- mvvmpropa adds a new attached property to a DependencyObject
(WPF only).
- mvvmpropdp adds a new dependency property to a DependencyObject
(WPF only).
- mvvmslpropa adds a new attached property to a DependencyObject
(Silverlight only).
- mvvmslpropdp adds a new dependency property to a DependencyObject
(Silverlight only).
Source code and Codeplex
The source code for the libraries is available on the
Codeplex site for the MVVM Light Toolkit. This is also a good place to post
suggestions/remarks/questions/discussions about the toolkit.
Support

We encourage the use of
StackOverflow for questions regarding MVVM Light Toolkit. StackOverflow
is an awesome site for questions related to programming. There is a huge community
of developers answering questions there. Please use the tag mvvm-light
to tag your questions.
StackOverflow "mvvm-light"
tag
Articles and tutorials about the MVVM "light" toolkit
By Laurent
New Versions:
Installation, Creation, Cleaning up
Videos:
- Understanding the MVVM Pattern:
Introduction to the the MVVM pattern. This is the talk I gave at MIX10 and a few
other occasions (this recording has extra 15 minutes for Windows Phone).
- Deep Dive MVVM:
An in-depth review of advanced techniques to implement decoupled applications. This
is the MIX11 talk.
-
Silverlight TV: An episode of Silverlight TV dedicated to the MVVM
Light Toolkit.
Documentation about specific components:
By others
-
MVVM Light Soup to Nuts (multipart series by Jesse Liberty). An excellent
series helping you to get started with various components of MVVM Light. Highly
recommended!
- Chris Koenig
about MVVM Development (multipart series by Chris Koenig). A great
series of articles about MVVM using MVVM Light. Highly recommended!
-
Silverlight 4 Beta, Drop Target et MVVM: (en francais, par Laurent Kempé) Utilise
EventToCommand pour passer un fichier au ViewModel via the new Drap&Drop functionality
in Silverlight 4.
-
MVVM Light Toolkit V2: (in English, by Laurent Kempé) Innoveo Solution is a
Swiss firm using the MVVM Light Toolkit in the application that they are developing
(cross
posted here).
- M-V-VM: ViewModels Intercommunication (in Italian,
by Corrado Cavalli)
- WPF and MVVM tutorial 08, messaging (in English,
by Raffaele Garofalo) (who talks about the Galactic toolkit, and I think it would
have been a cool name ;))
- Série d'articles sur l'approche MVVM pour WPF/Silverlight
(in French, by Richard Clark)
-
Etude de cas : application Silverlight avec Twitter et MVVM Light (in French,
by Richard Clark)
- Laurent Bugnion’s MVVM light toolkit for Silverlight
and WPF (in French, by Tweened)
-
MVVM light Toolkit für WPF und Silverlight (in German, forum thread with various
authors).
Donate
If you are so enclined, you can donate to MVVM Light Toolkit.
Or, if you prefer, you can pay me a beer next time we're in the same vicinity.
Really, it is OK too :)
Credits
The creation of this toolkit would not have been possible without the following
people:
Josh Smith
created the RelayCommand and gracefully allowed me to integrate it with very minor
changes inside the toolkit and to distribute it. He is also my "go to guy"
when I have issues (with my code, I mean).
Marlon Grech
started mentioning using a mediator pattern to communicate between ViewModels. This
discussion led me to create the Messenger class.
Jaime Rodriguez
had numerous discussions with me regarding the creation of ViewModels and gave me
food for thoughts...
Glenn Block
helped me finalize some thoughts and sparked a lot of new ones. He also gave me
great motivation to write this toolkit, and is an early tester and reviewer of the
toolkit.
Corrado
Cavalli gave me a lot of fantastic feedback and ideas for new features
or improving existing features, and was one of the very active early testers.
Laurent Kempé
was often here to keep me company in the wee morning hours, to talk about the direction
and features of the toolkit, and gave me very valuable feeback.
His team at Innoveo is using the MVVM Light Toolkit in
their new WPF application, and very supportive when it comes to improving and testing
the latest versions!
Brian Henderson and Rob Zelt helped test early versions and
gave precious feedback and suggestions to improve the features.
Steven Robbins
helped me with an issue and suggested I use a hack to solve it. "I think you can
safely say the worse line of code in your toolkit is my one :-)"
All the
WPF Disciples for the MANY discussions we had around the pattern
and the best way to implement it in various situations. You guys all rock my world!
Praises about the MVVM light toolkit
- MVVM Light Toolkit is simply awesome - @robymes
- Taking @LBugnion's MVVM Light Toolkit for a spin. Effing A! Totally easy. Mad props.
- @jmorrill
- #MVVM Light Toolkit is pretty nice. Light and to the point! Fills in all the gaps
we struggle with usually :) - @HydroMan
- I have been using #MVVM Light Toolkit by @LBugnion for a while now. It's light on
features, but still functional and very useful -
@ShiverCube
- @LBugnion is taking out some of the monotony of implementing MVVM http://digg.com/u15wEj
with MVVM light toolkit, the monotony killer :-) -
@gblock
- Just got the MvvmLight toolkit, looks great, good work! -
@CSkardon
- just want to say I love mvvm lite. I love the mediator pattern you have. I use it
evrywhere to decouple b/n view & vm interaction -
@CoreyGaudin
- The Mvvm Light toolkit v3 alpha 2 by @LBugnion
is very good. - @gulrog
- Agreed...your EventToCommand code is very, very useful. Already plugged it in and
stripped out the old way I was doing it. - @DanWahlin
- Tweaking my RIA/MVVM app, I think I have fallen in love with MVVM Light's Messenger,
a little too much... - @ShawnWildermuth