private static void OnSetCustomCommandParameterCallback(DependencyObject dep, DependencyPropertyChangedEventArgs e) { var textBox = dep as TextBox; if (textBox != null) { TextBoxTextChangedCommandBehavior behavior = GetOrCreateTextBoxBehavior(textBox); behavior.CommandParameter = e.NewValue; } }
private static TextBoxTextChangedCommandBehavior GetOrCreateTextBoxBehavior(TextBox textBox) { var behavior = textBox.GetValue(TextChangedCommandBehaviorProperty) as TextBoxTextChangedCommandBehavior; if (behavior == null) { behavior = new TextBoxTextChangedCommandBehavior(textBox); textBox.SetValue(TextChangedCommandBehaviorProperty, behavior); } return(behavior); }