basically I want to do something like this:
public static void OnPropertyChanged(this INotifyPropertyChanged changedObject, string propertyName)
{
var handler = changedObject.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(changedObject, e);
}
}
which gives "System.ComponentModel.INotifyPropertyChanged.PropertyChanged can only be used on the left-hand side of += or -="
I mean I can work around it by doing this:
public static void RaisePropertyChanged(this PropertyChangedEventHandler handler, object sender, string propertyName)
{
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(sender, e);
}
}
but the calling code doesn't look quite as nice:
PropertyChanged.RaisePropertyChanged(this, "Name");
vs this:
this.OnPropertyChanged("Name");
Not a big deal, but it'd be nice to be able to call it as if it was an instance method.