Esempio n. 1
0
 private static void OnSetDefaultTextAfterCommandExecutionCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
 {
     if (dependencyObject is TextBox textBox)
     {
         ReturnCommandBehavior behavior = GetOrCreateBehavior(textBox);
         behavior.DefaultTextAfterCommandExecution = e.NewValue as string;
     }
 }
Esempio n. 2
0
 private static void OnSetCommandCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
 {
     if (dependencyObject is TextBox textBox)
     {
         ReturnCommandBehavior behavior = GetOrCreateBehavior(textBox);
         behavior.Command = e.NewValue as ICommand;
     }
 }
Esempio n. 3
0
        private static ReturnCommandBehavior GetOrCreateBehavior(TextBox textBox)
        {
            if (!(textBox.GetValue(ReturnCommandBehaviorProperty) is ReturnCommandBehavior behavior))
            {
                behavior = new ReturnCommandBehavior(textBox);
                textBox.SetValue(ReturnCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
 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);
 }
 public void ShouldThrowArgumentNullExceptionIfTextboxIsNull()
 {
     var rcb = new ReturnCommandBehavior(null);
 }