首页 > 代码库 > 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的应用