Created
June 26, 2011 10:10
-
-
Save jittuu/1047463 to your computer and use it in GitHub Desktop.
This file contains 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
public class Formula<T> : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged = delegate { }; | |
private readonly Func<T> formula; | |
private readonly INotifyPropertyChanged source; | |
public Formula(INotifyPropertyChanged source, Func<T> formula, params string[] dependencyProperties) | |
{ | |
this.source = source; | |
this.formula = formula; | |
this.source.PropertyChanged += (sender, arg) => | |
{ | |
if (dependencyProperties.Any(p => p == arg.PropertyName)) | |
{ | |
PropertyChanged(this, new PropertyChangedEventArgs("Value")); | |
} | |
}; | |
} | |
public T Value | |
{ | |
get | |
{ | |
return formula(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment