I have several classes that implement the INotifyPropertyChanged
interface.
I'm now using Resharper and want to add the following standard code snippet to these classes:
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
The simplest solution I found so far is to delete the
public event PropertyChangedEventHandler PropertyChanged;
and implement the interface again, this time with the helper. Is there an easier way?
答案 0 :(得分:1)
如果您在属性上按Alt+Return
,您将有机会创建帮助程序。
注:鼠标已超过PropertyChanged
。