Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Can i Not call OnPropertyChanged when using [ImplementPropertyChanged]

I am implementing a class using fody ImplementPropertyChanged:

[ImplementPropertyChanged]
public class Translator
{
    public string this[string Text]
    {
        get
        {
            ...
        }
    }

    public void Invalidate()
    {
        OnPropertyChanged("item");
    }
}

Visual Studio tells me, that OnPropertyChanged is not defined. I thought, that ImplementPropertyChanged would define it.

How can I manually trigger a property change? In this case the indexer property changed.

like image 640
Nathan Avatar asked Feb 20 '26 12:02

Nathan


1 Answers

It does implement OnPropertyChanged during compile time, so it is not visible and available for you during development. If you like to trigger the property change manually, implement the interface by yourself or use a base class that implements it.

like image 181
doerig Avatar answered Feb 23 '26 01:02

doerig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!