I have this code and I am using it to raise the PropertyChanged event without passing the name of property to the function.
private void RaisePropertyChanged<TValue>(Expression<Func<TValue>> propertySelector)
{
var memberExpression = propertySelector.Body as MemberExpression;
if (memberExpression != null)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(memberExpression.Member.Name));
}
}
}
and I am calling it in this way:
this.RaisePropertyChanged(() => this.IsReady);
Which will raise the PropertyChanged event for the IsReady property. I like the idea as writing code in this way will help to change the name of the property very easily.
Now I want to use the same technique to pass the name and value of a property to a method. Is there any way that I can do this?