private static void OnSetCommandCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { TextBox textBox = dependencyObject as TextBox; if (textBox != null) { ReturnCommandBehavior behavior = GetOrCreateBehavior(textBox); behavior.Command = e.NewValue as ICommand; } }
private static void OnSetDefaultTextAfterCommandExecutionCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { TextBox textBox = dependencyObject as TextBox; if (textBox != null) { ReturnCommandBehavior behavior = GetOrCreateBehavior(textBox); behavior.DefaultTextAfterCommandExecution = e.NewValue as string; } }
private static ReturnCommandBehavior GetOrCreateBehavior(TextBox textBox) { ReturnCommandBehavior behavior = textBox.GetValue(ReturnCommandBehaviorProperty) as ReturnCommandBehavior; if (behavior == null) { behavior = new ReturnCommandBehavior(textBox); textBox.SetValue(ReturnCommandBehaviorProperty, behavior); } return(behavior); }