コード例 #1
0
        private static void OnSetCommandParameterCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TextBox tb = d as TextBox;

            if (tb != null)
            {
                TextBoxTextChangedCommandBehavior behavior = GetOrCreateBehavior(tb);
                behavior.CommandParameter = e.NewValue;
            }
        }
コード例 #2
0
        private static TextBoxTextChangedCommandBehavior GetOrCreateBehavior(TextBox tb)
        {
            TextBoxTextChangedCommandBehavior behavior =
                tb.GetValue(TextChangedCommandBehaviorProperty) as TextBoxTextChangedCommandBehavior;

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

            return(behavior);
        }