Data Binding Notifications绑定通知 GIS

The standard way for a View Model to serve as a binding source is by implementing the INotifyPropertyChanged interface defined in the System.ComponentModel namespace. This interface has an exceptionally simple definition:
public interface INotifyPropertyChanged { event PropertyChangedEventHandler PropertyChanged; }
The PropertyChangedEventHandler delegate is associated with the PropertyChangedEventArgs class, which defines one property: PropertyName of type string. When a class implements INotifyPropertyChanged, it fires a PropertyChanged event whenever one of its properties changes.

public class SimpleViewModel : INotifyPropertyChanged

{ double totalScore;

public event PropertyChangedEventHandler PropertyChanged;

public double TotalScore

{

set { if (totalScore != value)

{

totalScore = value;

if (PropertyChanged != null)

PropertyChanged(this, new PropertyChangedEventArgs("TotalScore"));

}

}

get { return totalScore; }

}

}

原文地址:https://www.cnblogs.com/gisbeginner/p/2670431.html