赞
踩
/// <summary> /// 属性改变通知类 /// </summary> public class PropertyNotifyBase : INotifyPropertyChanged { /// <summary> /// 属性改变事件 /// </summary> public event PropertyChangedEventHandler PropertyChanged; /// <summary> /// 更新属性 /// </summary> /// <typeparam name="T">属性类型</typeparam> /// <param name="propertyValue">属性值</param> /// <param name="newValue">新值</param> /// <param name="propertyName">属性名称</param> public void UpdateProperty<T>(ref T propertyValue, T newValue, [CallerMemberName]string propertyName = "") { if (!object.Equals(propertyValue, newValue)) { propertyValue = newValue; UpdateProperty(propertyName); } } /// <summary> /// 更新属性 /// </summary> /// <param name="propertyName">属性名称</param> protected void UpdateProperty(string propertyName) { if (this.PropertyChanged != null) this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。