Created
June 8, 2012 11:57
-
-
Save bobbychopra/2895245 to your computer and use it in GitHub Desktop.
Notify Property Changed using Expression Tree
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
private string _filePath; | |
public string FilePath | |
{ | |
get { return _filePath; } | |
set { _filePath = value; NotifyOfPropertyChange(()=> FilePath); } | |
} | |
private void NotifyOfPropertyChange<TValue>(Expression<Func<TValue>> propertySelector) | |
{ | |
if (PropertyChanged != null) | |
{ | |
var memberExpression = propertySelector.Body as MemberExpression; | |
if (memberExpression != null) | |
{ | |
PropertyChanged(this, new PropertyChangedEventArgs(memberExpression.Member.Name)); | |
} | |
} | |
} | |
public event PropertyChangedEventHandler PropertyChanged; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment