예제 #1
0
        private static void OnSetCommandParameterCallback(
            DependencyObject dependencyObject,
            DependencyPropertyChangedEventArgs e)
        {
            TextBox tb = dependencyObject as TextBox;

            if (tb != null)
            {
                TextBoxMouseDownCommandBehavior behavior = GetOrCreateBehavior(tb);
                behavior.CommandParameter = e.NewValue;
            }
        }
예제 #2
0
        private static TextBoxMouseDownCommandBehavior GetOrCreateBehavior(TextBox textBox)
        {
            TextBoxMouseDownCommandBehavior behavior =
                textBox.GetValue(SelectCommandBehaviorProperty) as TextBoxMouseDownCommandBehavior;

            if (behavior == null)
            {
                behavior = new TextBoxMouseDownCommandBehavior(textBox);
                textBox.SetValue(SelectCommandBehaviorProperty, behavior);
            }

            return(behavior);
        }