示例#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);
        }