private static void OnSetDefaultTextAfterCommandExecutionCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { if (dependencyObject is TextBox textBox) { ReturnCommandBehavior behavior = GetOrCreateBehavior(textBox); behavior.DefaultTextAfterCommandExecution = e.NewValue as string; } }
private static void OnSetCommandCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { if (dependencyObject is TextBox textBox) { ReturnCommandBehavior behavior = GetOrCreateBehavior(textBox); behavior.Command = e.NewValue as ICommand; } }
private static ReturnCommandBehavior GetOrCreateBehavior(TextBox textBox) { if (!(textBox.GetValue(ReturnCommandBehaviorProperty) is ReturnCommandBehavior behavior)) { behavior = new ReturnCommandBehavior(textBox); textBox.SetValue(ReturnCommandBehaviorProperty, behavior); } return(behavior); }
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); }
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; }
private static IReturnCommandBehavior ResolveCommandBehavior(DependencyObject ctrl) { IReturnCommandBehavior behavior; if (ctrl.GetType() == typeof(TextBox)) behavior = new ReturnCommandBehavior((TextBox)ctrl); else if (ctrl.GetType() == typeof(PasswordBox)) behavior = new pwReturnCommandBehavior((PasswordBox)ctrl); else behavior = null; return behavior; }
public void ShouldThrowArgumentNullExceptionIfTextboxIsNull() { var rcb = new ReturnCommandBehavior(null); }