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