我在使用PostSharp实现INotifyPropertyChanged
时遇到一点小问题。PostSharp会在编译后添加PropertyChangedEventHandler
和PropertyChanged
,但我也需要从C#中响应变化。
Model a = new Model();
a.PropertyChanged += a_PropertyChanged;
模型实现;
[NotifyPropertyChanged]
internal class Model
{
public string A { get; set; }
public string B { get; set; }
public string C { get { return string.Format("{0} - {1}", A, B); } }
}
我尝试了不同的方法来添加处理程序,但是都没有成功。有什么方法可以做到这一点吗?