Exemplo n.º 1
0
        private static void OnSetCommandCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            TextBox textBox = dependencyObject as TextBox;

            if (textBox != null)
            {
                TextBoxCommandBehavior behavior = GetOrCreateBehavior(textBox);
                behavior.Command = e.NewValue as ICommand;
            }
        }
Exemplo n.º 2
0
        private static TextBoxCommandBehavior GetOrCreateBehavior(TextBox textBox)
        {
            TextBoxCommandBehavior behavior = textBox.GetValue(KeyUpCommandBehaviorProperty) as TextBoxCommandBehavior;

            if (behavior == null)
            {
                behavior = new TextBoxCommandBehavior(textBox);
                textBox.SetValue(KeyUpCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }