Making it easier with frameworks
We can save ourselves a little effort by taking advantage of one of the many MVVM frameworks freely available on the Web.
Tip
See Appendix A, MVVM Frameworks for a list of frameworks.
We are now going to update our code to use the MVVM Light framework by following the steps mentioned next:
Tip
If you haven't downloaded the MVVM Light framework then download the framework. See Chapter 2, Introduction to MVVM for details. Also note that there is now an MVVM Light Nuget package (http://nuget.org/packages/mvvmLight) available, which would be the preferred way to install the framework..
Copy
GalaSoft.MvvmLight.WPF4.dll
to theLib
directory in the solution, as shown in the following screenshot. This assembly contains theRelayCommand
class that we will be using.Add browse reference from
Northwind.ViewModel
toGalaSoft.MvvmLight.WPF4.dll
.Delete the
Command.cs
file fromNorthwind.Application
.Open
MainWindowViewModel.cs
, add a using statement forGalaSoft.MvvmLight.Command...