• 【C#】实现INotifyPropertyChanged的3种方法


     class StudentItemViewModel:INotifyPropertyChanged
        {
            public event PropertyChangedEventHandler PropertyChanged;
    
            public Student Student { get; set; }
    
    
            private bool _isSelected;
            public bool IsSelected
            {
                get { return _isSelected; }
                set
                {
                    _isSelected = value;
                    this.PropertyChanged(this,new PropertyChangedEventArgs("IsSelected"));
                    //NotifyPropertyChanged("IsSelected");
                }
            }
    
    
    
            private void NotifyPropertyChanged(string Name)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(Name));
                }
            }
    
    
        }
    
    
    
        class NotifyCationObject : INotifyPropertyChanged
        {
            private string GetPropertyName<T>(Expression<Func<T>> action)
            {
                var expression = (MemberExpression)action.Body;
                return expression.Member.Name;
            }
    
            protected void NotifyPropertyChanged<T>(Expression<Func<T>> action)
            {
                string name = GetPropertyName<T>(action);
                NotifyPropertyChanged(name);
            }
    
            private event PropertyChangedEventHandler PropertyChanged;
    
            private void NotifyPropertyChanged(string Name)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(Name));
                }
            }
        }
  • 相关阅读:
    Shell脚本实现用户数据导入
    Sping Cloud 微服务框架学习
    Redis学习笔记
    HTML+CSS实现简单三级菜单
    CSS Float浮动所带来的奇怪现象
    CSS如何清除浮动流的多种方案
    ECMAScript/JS 基础知识讲解
    Python的生成器
    Python包的导入说明
    Paramiko模块简单使用
  • 原文地址:https://www.cnblogs.com/wywnet/p/3596733.html
Copyright © 2020-2023  润新知