The basic idea of MVVM is, that view models expose properties to which the views bind. Ordinary C# properties don’t come with a mechanism to inform listeners of changes, so the binding mechanism of WPF relies on an interface named INotifyPropertyChanged. This interface consists of only one event: PropertyChanged.

Since every view model should be able to inform a listener about changes to its properties, we will implement the interface in ViewModelBase; furthermore we’ll create a method, so that derived classes can fire this event:

By the way: When I was implementing the NotifyPropertyChanged() method, VS 2017 offered a “simplification” of the method: (To be honest: I didn’t even know that this variation is possible…)

Now, honestly: do you really think, that this is “simpler”? Coming from C and C++ I’ve had such “simple” constructs for over 15 years; some of those simplifications took developers hours to understand and they actually don’t add any advantage to the application… Most of the “short cuts” that Microsoft has invented in the last of couple of years (lambda expressions etc.) don’t add any value to the application. Actually it seems as if those short cuts mainly exist because developers that consider themselves being better than other developers, always need something to prove their superiority…
My favourite simplification is still this one – can you figure what it does? (All variables are considered to be ints.)

You see, what “simplification” can do?
So, I’ll stay with the “old” version…

Note: From .NET 4.5 on you can use the CallerMemberName attribute to simplify (pun intended) the call of the NotifyPropertyChanged() method: (The property name is inserted automatically when the method is called without parameters.)

In the next part we’ll start with the view models of the two data entry pages.