zoukankan      html  css  js  c++  java
  • WPF 自定义NotifyPropertyChanged

    该工具类实现INotifyPropertyChanged接口

        /// <summary>
        /// 实现了属性更改通知的基类
        /// </summary>
        public class BaseNotifyPropertyChanged : System.ComponentModel.INotifyPropertyChanged
        {
            /// <summary>
            /// 属性值变化时发生
            /// </summary>
            /// <param name="propertyName"></param>
            protected virtual void OnPropertyChanged(string propertyName)
            {
                if (this.PropertyChanged != null)
                    this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
    
            /// <summary>
            /// 属性值变化时发生
            /// </summary>
            /// <param name="propertyName"></param>
            protected virtual void OnPropertyChanged<T>(Expression<Func<T>> propertyExpression)
            {
                var propertyName = (propertyExpression.Body as MemberExpression).Member.Name;
                this.OnPropertyChanged(propertyName);
            }
    
            public virtual event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        }
    View Code

    使用时继承此类,然后在VM中的属性get使用:OnPropertyChanged(()=>PropertyName)

  • 相关阅读:
    video标签
    正则表达式
    BOM和DOM
    css样式属性
    js简介
    格式与布局
    CSS样式表
    表单
    redis学习心得之三-【java操作redis】
    redis学习心得之二【redis主从配置】
  • 原文地址:https://www.cnblogs.com/callyblog/p/8094757.html
Copyright © 2011-2022 走看看