Skip to content

Instantly share code, notes, and snippets.

@msiddiqi
Created March 20, 2014 13:46
Show Gist options
  • Save msiddiqi/9664070 to your computer and use it in GitHub Desktop.
Save msiddiqi/9664070 to your computer and use it in GitHub Desktop.
internal class ViewModelBase : INotifyPropertyChanged
{
#region Implementation INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged = delegate { };
protected void OnPropertyChanged(Expression<Func<object>> expression)
{
if (expression == null || !(expression.Body is MemberExpression))
{
return;
}
PropertyChanged(this, new PropertyChangedEventArgs(((MemberExpression)expression.Body).Member.Name));
}
#endregion Implementation INotifyPropertyChanged
}
@Fireforge
Copy link

This code sample works for Reference typed member values, but NOT for Value typed members.
See this dotnetfiddle for an example of the failure: https://dotnetfiddle.net/Xgpo5W

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment