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