team

MVVM Light Toolkit

MVVM Light Toolkit is an open source platform for building applications using the MVVM pattern. The main goal of the toolkit is to accelerate the creation and development of MVVM applications in WPF, Silverlight, Windows Store, Windows Phone, and Xamarin.

MVVM Light is the library I’ve been using since early versions. There are many other implementations of the MVVM pattern available, such as Prism, and some developers even choose to deploy their own framework.

Let’s get started

To start, let me explain that you need Windows 10 Pro (to use Hyper-v to run the emulators) and Visual Studio 2015 as an IDE. I suggest that you install the free Visual Studio 2015 Community Edition, which contains almost all the features you need for development.

Launch Visual Studio 2015 and create a new project template in Visual C#, select Windows, and then select Empty Application (Universal Windows).

Installing the MVVM Light Toolkit

There are various ways to install the MVVM Light Toolkit, but for this demonstration, we’ll use Nuget.

Before you install MVVM Light Toolkit via nuget, I want to inform those who have been using MVVM Light Toolkit for Windows 8 and Windows 8.1 development (phone or desktop) that the Nuget team has changed the implementation for UWP and decided to no longer support the content files and PowerShell script. . So, the current version of MVVM Light Toolkit (5.2.0) will not create ViewModelLocator for you, nothing will be added to the resources and no code will be added to App.xaml as it was before. You will have to add them manually.

The ServiceLocator is responsible for getting ViewModel instances using the SimpleIoc.Default implementation provided by MVVM Light. By registering them through the SimpleIoc.Default instance in the constructor, we can get these instances from the Views through the public properties defined in the locator class.

Then we can register this locator as a global static resource in App.xaml, so it is available for use by all pages. Instances of these resources are created automatically both at runtime and during development, ensuring that our samples and live data are ready.