How do I notify the user interface of a change using the readonly property?

In WPF, I only have a property with get {}. The value comes from the return method. NotifyPropertyChanged is often used in the property set {}. It can then notify the user interface and the updated value is displayed. But only with get {} there is no way to determine if a new or different value is available, since you need to execute a proven method.

Is there a way to update the user interface without having to save a local value containing the last value from the method, in which case would you need to compare the comparison?

+5
source share
2 answers

get {} , , .

: ? , , NotifyPropertyChanged , , , WPF .

WPF , PropertyChanged - .


:

, . , , , . INotifyPropertyChanged, "" NotifyPropertyChanged. , , .

, , PropertyChanged string.Empty PropertyName EventArgs. , all WPF. , , :

this.Model.DoSomething(); // This will change 1+ properties
this.NotifyPropertyChanged(string.Empty); // Refresh our entire UI

, , , , , .

+9

. , INotify . .

private int _myvalue = 3;

  public bool MyProperty
    {
        get { return IsAProperty(); }
    }

public bool IsAProperty()
{
    return _myvalue + 1 == 4;
}
public void SetValue(int value)
{
    _myvalue = value;
    NotifyPropertyChanged(MyProperty);
}
+2

All Articles