首页 > 代码库 > 1、ViewModel类的构建和INoyifyPropertyChanged的应用
1、ViewModel类的构建和INoyifyPropertyChanged的应用
public class SampleItem : INotifyPropertyChanged { public SampleItem() { } private string title; public string Title { get { return title; } set { if (value != title) { title = value; NotifyPropertyChanged("Title"); } } } private string subTitle; public string SubTitle { get { return subTitle; } set { if (value != subTitle) { subTitle = value; NotifyPropertyChanged("SubTitle"); } } } private string itemImage; public string ItemImage { get { return itemImage; } set { if (value != itemImage) { itemImage = value; NotifyPropertyChanged("ItemImage"); } } } private string gprop; public string TargetGroup { get { return gprop; } set { if (value != gprop) { gprop = value; NotifyPropertyChanged("TargetGroup"); } } } private ObservableCollection<SampleItem> items = new ObservableCollection<SampleItem>(); public ObservableCollection<SampleItem> Items { get { return items; } set { if (value != items) { items = value; NotifyPropertyChanged("Items"); } } } public event PropertyChangedEventHandler PropertyChanged; protected void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } }
1、ViewModel类的构建和INoyifyPropertyChanged的应用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。