Building a simple MVVM framework
It should be clear at this point that MVVM-based applications have a lot of elements in common, such as change notifications and commands. It would be beneficiary to create a reusable framework that we can simply leverage in many applications. Although there are several good frameworks out there (most are free), building such a framework ourselves will enhance our understanding and may prove easier to extend than other frameworks, which we may be less familiar with.
Getting ready
Make sure Visual Studio is up and running.
How to do it...
We'll create a reusable class library to serve as a basis of a simple MVVM framework and use it (and extend it) in later recipes:
Create a new WPF
UserControl
Class Library project namedCH07.CookbookMVVM
. Make sure the checkbox Create directory for solution is checked. We don't need any user controls, but this automatically adds WPF assembly references.Delete the file
UserControl1.xaml
.Add the class
ObservableObject
from the...