您的位置:首页 > 其它

Data Binding Notifications绑定通知

2012-09-04 15:06 225 查看
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; }

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: