Search code examples
c#winformsinotifypropertychangedfodyfody-propertychanged

Fody.PropertyChanged doesn't fire on inherited Property


I have a Control which inherits from NumericUpDown in WinForms.

I want to handle changes to the DecimalPlaces-Property of NumericUpDown, therefore I have both tried declaring a

void OnDecimalPlacesChanged()
{
    MessageBox.Show("Moeeep");
}

and also manually subscribing the PropertyChanged-event in the ctor manually. It seems to just not fire when I update DecimalPlaces and I have no idea why.


Solution

  • Since Control does not implement INotifyPropertyChanged, only your class does. Because of that, the Control doesn't raise any event when the DecimalPlaces changes. No framework can inject that into their code.

    For now, the best thing you have is to override the UpdateEditText method. It is called when the DecimalPlaces property changes. Note that this is of course not the only reason the method is called, so you might have a problem there...