기본적으로 나는 다음과 같이하고 싶다.확장 메서드로 정식 OnPropertyChanged 메서드를 작성하는 방법이 있습니까?
public static void OnPropertyChanged(this INotifyPropertyChanged changedObject, string propertyName)
{
var handler = changedObject.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(changedObject, e);
}
}
public static void OnPropertyChanged(this INotifyPropertyChanged changedObject, string propertyName)
{
var handler = changedObject.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(changedObject, e);
}
}
"System.ComponentModel.INotifyPropertyChanged.PropertyChanged는 + = 또는 - ="의 왼쪽에서만 사용할 수있다.
하지만 호출 코드가 꽤 멋지게 보이지 않습니다.
this.OnPropertyChanged("Name");
큰 문제는 아니지만, 인스턴스 메서드처럼 호출 할 수 있으면 좋을 것입니다.
[이 블로그 게시물] (http://www.gamlor.info/wordpress/?p=832) 및 첨부 파일을 확인하십시오. –