MVVM Light is extremely popular to build client applications in XAML. It supports Windows Presentation Foundation, Silverlight, Windows 8 (RT), and Windows Phone. This toolkit consists of helper components, project and item templates, code snippets, and recommendations on building a decoupled architecture for your application. MVVM Light works great in Blend and the Visual Studio designer to enable designer-developer workflow to improve the application's user experience. MVVM Light also makes it easier to decouple the application's components and to maintain it. This course introduces each component with in-depth explanations and samples. It also shows examples inspired from real-life applications where MVVM Light is used successfully.
Laurent works as Senior Director for IdentityMine, one of the leading companies (and Gold Partner) for Microsoft technologies such as Windows Presentation Foundation, Silverlight, Pixelsense, Windows 8, Windows Phone, XBOX and generally User Experience. He is based in Zurich Switzerland.
Section Introduction Transcripts
Section Introduction Transcripts
Introduction to the MVVM Hello and welcome to this course. My name is Laurent Bugnion, and I'm going to talk to you about the MVVM Light Toolkit. MVVM Light is an open-source toolkit, a suite of components which will help you to develop decoupled applications according to the Model-View-ViewModel Pattern. So Toolkit is available for all XAML-based frameworks; for example, Windows Presentation Foundation, Silverlight, Windows Phone, and Windows RT. The MVVM Pattern is very popular for XAML developers. For some of you, it is a very well-known pattern, but for others it is quite new, and this is why we are going to start with an introduction to MVVM. First, we are going to build a simple application and we are not going to use the Model-View-ViewModel Pattern here, but we are going to use a classic architecture and some events. We are going to see some of the disadvantages of this approach. And finally, we will have a small theory part about understanding MVVM, understanding which layers are playing together, and how they communicate. In the next module, we are going to refactor this application to a Model-View-ViewModel application, and this will help us to understand how the basic components of MVVM work and how they can be composed together to create a more maintainable and more testable application.
Refactoring the App to MVVM In the previous module, we built a Windows Phone Application without using the Model-View-ViewModel Pattern. We saw some of the disadvantages of this tightly coupled approach using quite a lot of events and code behind. All those principles apply to all XAML-based frameworks, not just Windows Phone Apps. And similarly, what we will do in this module applies to all XAML-based frameworks as well. In this module, we will refactor the application to use a Model-View-ViewModel Pattern. This is going to solve the disadvantages that we saw in the previous module. First of all, we will start by making the model, the Friend object, observable, so that we can apply DataBindings directly to those properties. We are going to create a ViewModel for the main View, and we are going to create some View services that the ViewModel can call in an abstracting manner, in order to execute operations on the View, such as showing dialogs or doing some navigation. Then we will bind the ViewModel to the View in order to create a One-to-One relationship between those two items. We will add some design time data and that will give us the opportunity to use Blend to do some visual design. Finally, we will add a unit test to your application and we will see how we can mock the services in order to simulate test conditions.
The Extras Welcome to Module 4 of the MVVM Light course. In the previous module, we talked about the core components of MVVM Light, the ObservableObject, ViewModelBase, RelayCommand, Messenger, and the DispatcherHelper. We'll start this module with a discussion of how Views are bound to their respective ViewModels, and we'll discuss various strategies that we recommend using in MVVM Light applications. There are two more components that I would like to study in this module; the SimpleIoc and the EventToCommand. These two components are placed in a separate assembly called Extras. First we will start with an introduction to the Extras assembly, and why it is even there. Then, we will have a detailed study of the SimpleIoc component, an IOC container that is well suited for MVVM applications. Later, we will talk about the EventToCommand behavior and understand what behaviors are and what this particular element does. At the end of this module, you will understand the standard structure of an MVVM Light application and understand how the Views are bound to the ViewModels. You will also understand why MVVM Light comes in two separate assemblies, and you will know how to use a SimpleIoc and the EventToCommand components.
Installing the MVVM Light Toolkit and Additional Components Welcome to Module 5 of the MVVM Light Toolkit reference course. In previous modules, we saw what the advantages are of an MVVM architecture over an event-based architecture for XAML-based applications. We understood what steps were needed to refactor an event-based app to an MVVM app. And we saw that some repetitive operations could benefit from some automation. This is when we introduce the MVVM Light Toolkit's components, starting with the Code DLL and then following up with the Extras DLL. This rounded up the presentation of the first-half of the toolkit's elements. In this module, we will introduce additional elements, such as project templates and code snippets. These additional tools are the reason why we don't talk of MVVM Light as a framework. In fact, it is a suite of tools, as well as a guidance to build applications, which is why the name toolkit is more appropriate. First, we will see how you can install MVVM Light in your application using NuGet, or, on your PC using an installer. We will understand the differences between these two approaches. Then, after the whole toolkit is installed, we will learn more about the additional components, starting with the code snippets. We will understand how they can help you to be more productive in Visual Studio, especially when writing repetitive code. Then, we will review a typical application created with an MVVM Light project template and see how it is structured and what are the advantages over a classic app. We will also talk about the item templates used to create new Views, new ViewModels, or a new ViewModelLocator.