Created
March 20, 2014 13:46
-
-
Save msiddiqi/9664070 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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