WinData.cs 1.52 KB
using System.ComponentModel;

namespace OS.Spin.ViewModle.Models
{
    public class WinData : INotifyPropertyChanged
    {
        //public event PropertyChangedEventHandler PropertyChanged;
        //C#中私有变量默认都是下划线开头的
        private int _runtimes;  //私有
        //public int _runtimesOne; //私有
       
        public int runtimes
        {
            //获取值时将私有字段传出
            get { return _runtimes; }
            set
            {
                //赋值时将值传给私有字段
                _runtimes = value;
                OnPropertyChanged("runtimes");
                //一旦执行了赋值操作说明其值被修改了,则立马通过
                //INotifyPropertyChanged接口告诉UI(IntValue)被修改了
                //PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("runtimes"));
            }
        }
        //public int runtimesOne
        //{
        //    get { return _runtimesOne; }
        //    set
        //    {
        //        _runtimesOne = value;
        //        //_runtimes = _runtimesOne;
        //        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("runtimes"));
        //    }
        //}
        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string strPropertyInfo)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(strPropertyInfo));
            }
        }
    }
}