Last active
March 21, 2016 11:56
-
-
Save ryupold/2f86f54ad1013c3005d2 to your computer and use it in GitHub Desktop.
simplifies creation of DependencyProperties (XAML)
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 static class PropertyUtils | |
{ | |
public static DependencyProperty CreateProperty<TProperty, TOwner> (string propertyName, Action<TOwner, TProperty, TProperty> onChange, TProperty defaultValue=default(TProperty)) where TOwner : class | |
{ | |
return DependencyProperty.Register(propertyName, typeof (TProperty), typeof (TOwner), | |
new PropertyMetadata(defaultValue, (o, args) => | |
{ | |
onChange(o as TOwner, (TProperty)args.OldValue, (TProperty)args.NewValue); | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment