标签:更新ui har 删除 dev not change class ret val
ObservableCollection<T> 只有项添加或删除才会更新UI
要想属性发生变动后立刻更新到UI,必须继承 INotifyPropertyChanged 接口,示例如下
public class SurfaceDetail: INotifyPropertyChanged { //不更新到界面的属性 public string name { get; set; } //以下是更新到界面的属性 private string _color; public string color { get { return _color; } set { _color = value; OnPropertyChanged("color"); } } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } }
标签:更新ui har 删除 dev not change class ret val
原文地址:http://www.cnblogs.com/dingguidong/p/6411095.html