Having a base class is a method that even MVVM MVVM libraries do. There is no shortage of this.
Yes, you can only have one base class for the C # class, but it implements several interfaces. For your case, all you have to do is say that the base class implements INPC and calls it ViewModelBase
Now, if you currently have class X inherit from Class A , just make A inherit from ViewModelBase .
Thus, you are thus forcing your current base classes to inherit from this new INPC rendering class, and you do not have code duplication to implement INPC in any of your derived classes
Update
In your special case, when for some reason you are tied to one already having a different base class, and with the restriction of not saying something like a public implementation of INPC passed to this object as a member variable,
You can try a look at this:
Fody and in particular addon PropertyChanged - Addon
This will hopefully help you, since it implements the INPC implementations themselves, so you donβt need to copy the paste code, and then it allows you to get some kind of custom base class (you still need to specify INPC, but this is just the interface here)
source share