有没有一种方法可以在调用Set时仍然触发更改事件(例如< strong> INotifyPropertyChanged ),同时继续使用自动实现属性?
而不是:
而不是:
private string _value;
public string Value
{
get
{
return this._value;
}
set
{
this._value = value;
this.ValueChanged(this,EventArgs.Empty);
}
}
我可以直接这样做吗:
public string Value
{
get;
set
{
this.ValueChanged(this,EventArgs.Empty);
}
}
尽管setter看起来不对,但是有没有可能在不向我的类中添加后备存储变量的情况下完成这个任务?
更新:看起来没有标准解决方案符合我的懒惰目标,我认为最好的解决方案是使用CodeRush或Resharper为我生成所有后备存储。