private static void CommandProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { Control element = dependencyObject as Control; if (element != null) { KeyUpBehavior behavior = GetOrCreateBehavior(element); behavior.Command = e.NewValue as ICommand; } }
private static KeyUpBehavior GetOrCreateBehavior(Control element) { KeyUpBehavior behavior = element.GetValue(KeyUpBehaviorProperty) as KeyUpBehavior; if (behavior == null) { behavior = new KeyUpBehavior(element); element.SetValue(KeyUpBehaviorProperty, behavior); } return(behavior); }
public static void SetKeyUpBehavior(DependencyObject obj, KeyUpBehavior value) { obj.SetValue(KeyUpBehaviorProperty, value); }