A very common and popular way to synchronize data between the model and the view in WPF is using DataBinding. The value of the model is transferred to the view once, when the binding is initialized. But for every subsequent change, the model must notify the binding to transfer the value again. This is done by implementing the
INotifyPropertyChangedinterface on the model.
In the setter of every bound property there must be some code to raise the
PropertyChanged event, passing the name of the modified property as a
string. This has some disadvantages:
- You cannot use Auto-properties
- The property name is passed as a string. This brings ugly errors, when you forgot to change the string after a rename.
- Every property needs extra code