Generic c# - Raise an event whenever a property's value changed? - Stack Overflow

PHOTO EMBED

Wed Jul 22 2020 21:22:57 GMT+0000 (Coordinated Universal Time)

Saved by @AsiBela #cs

public class MyClass : INotifyPropertyChanged
{
    private string imageFullPath;

    protected void OnPropertyChanged(PropertyChangedEventArgs e)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
            handler(this, e);
    }

    protected void OnPropertyChanged(string propertyName)
    {
        OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
    }

    public string ImageFullPath
    {
        get { return imageFullPath; }
        set
        {
            if (value != imageFullPath)
            {
                imageFullPath = value;
                OnPropertyChanged("ImageFullPath");
            }
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
}
content_copyCOPY

https://stackoverflow.com/questions/2246777/raise-an-event-whenever-a-propertys-value-changed