Simplifying INotifyPropertyChanged

Honestly I’m not sure if I made this class or if someone else made it but it has been laying around for years and been a part of my toolbox so I thought I would share it 🙂

Normally a implementation of the INotifyPropertyChanged would look something like this:

I think it’s a risk and a bit of a hassle to have to enter a string for every parameter. Spelling misstakes will eventuelly occur. Instead I use a wrapper that automatically takes the name of the calling member.

The use of this wrapper will then look like this:

In XAML you will bind the property to ExampleParameter and voila, no hardcoded strings being passed around to the INotifyProperty interface anymore.

Leave a Reply

Your email address will not be published. Required fields are marked *