예제 #1
0
        private static void OnSetCustomCommandParameterCallback(DependencyObject dep,
                                                                DependencyPropertyChangedEventArgs e)
        {
            var textBox = dep as TextBox;

            if (textBox != null)
            {
                TextBoxTextChangedCommandBehavior behavior = GetOrCreateTextBoxBehavior(textBox);
                behavior.CommandParameter = e.NewValue;
            }
        }
예제 #2
0
        private static TextBoxTextChangedCommandBehavior GetOrCreateTextBoxBehavior(TextBox textBox)
        {
            var behavior = textBox.GetValue(TextChangedCommandBehaviorProperty) as TextBoxTextChangedCommandBehavior;

            if (behavior == null)
            {
                behavior = new TextBoxTextChangedCommandBehavior(textBox);
                textBox.SetValue(TextChangedCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }