mvvm INotifyPropertyChanged

先看数据模型:

public class VModel : INotifyPropertyChanged
    {
        private string _Name;
 
        public string Name
        {
            get { return _Name; }
            set
            {
                if (_Name != value)
                    _Name = value;
                OnPropertyChanged("Name");
            }
        }
 
        private List<string> _Desciption;
 
        public List<string> Desciption
        {
            get { return _Desciption; }
            set {
                if (_Desciption != value)
                    _Desciption = value;
                OnPropertyChanged("Desciption");
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        protected void OnPropertyChanged(string propertyName)
        {
            if (string.IsNullOrEmpty(propertyName)) throw new ArgumentNullException("propertyName");
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
        }
 
    }

猜你喜欢

转载自blog.csdn.net/zhang8593/article/details/129420203
今日推荐