MVVM - PropertyChanged in Model or ViewModel?

c#, mvvm

Solution

The `INotifyPropertyChanged` (INPC) interface is used for `Binding`.

So, in the average case, you want to implement it in your `ViewModel`.

The `ViewModel` is used to decouple the `Model` from your `View`, so there is no need to have INPC in your `Model`, as you do not want `Bindings` to your `Model`.

In most cases, even for smaller properties, you still have a very small `ViewModel`.

If you want a solid base for `MVVM`, you are probably going to use some kind of MVVM Framework like caliburn.micro. Using it will give you a `ViewModelBase` (or here `NotifyPropertyChangedBase`) so that you do not have to implement those interface members yourself and can just use `NotifyOfPropertyChange(() => MyProperty)`, which is way easier and less error prone.

UPDATE As there seem to be many Windows Forms developers out there, here is an excellent article that will give deeper understanding of what MVVM is about: MSDN Magazine on MVVM

I have linked especially the part about the datamodel, that the question is about.

Problem

I have gone through a few MVVM tutorials and I have seen this done both ways. Most use the ViewModel for PropertyChanged (which is what I have been doing), but I came across one that did this in the Model. Are both methods acceptable? If so, what are the benefits/drawbacks of the different methods?

Original source

Related problems