private static void OnSetCommandParameterCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { TextBox tb = d as TextBox; if (tb != null) { TextBoxTextChangedCommandBehavior behavior = GetOrCreateBehavior(tb); behavior.CommandParameter = e.NewValue; } }
private static TextBoxTextChangedCommandBehavior GetOrCreateBehavior(TextBox tb) { TextBoxTextChangedCommandBehavior behavior = tb.GetValue(TextChangedCommandBehaviorProperty) as TextBoxTextChangedCommandBehavior; if (behavior == null) { behavior = new TextBoxTextChangedCommandBehavior(tb); tb.SetValue(TextChangedCommandBehaviorProperty, behavior); } return(behavior); }