我将Postharp实现到我用MVVM-Light制作的现有项目中。我在viewmodel中定义了我的属性,如下所示:
public WindowState WindowState
{
get
{
return windowState;
}
set
{
if(windowState != value)
{
windowState = value;
RaisePropertyChanged("WindowState");
}
}
}
我实施了PostSharp的NotifyPropertyChanged
属性:
[NotifyPropertyChanged]
public class MainViewModel : ViewModelBase
{
public WindowState WindowState { get; private set; }
}
现在我在启动程序时遇到了这个编译错误:
Class ViewModels.MainViewModel implements INotifyPropertyChanged but does not define an OnPropertyChanged method with the following signature: void OnPropertyChanged(string propertyName)
我是否必须在我的viewmodel中实现这样的方法,甚至是覆盖ViewModelBase?
答案 0 :(得分:0)
仅将属性[NotifyPropertyChanged]
应用于班级ViewModelBase
。它将通过继承进入后代类。