示例#1
0
        private static void CommandProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            Control element = dependencyObject as Control;

            if (element != null)
            {
                KeyUpBehavior behavior = GetOrCreateBehavior(element);
                behavior.Command = e.NewValue as ICommand;
            }
        }
示例#2
0
        private static KeyUpBehavior GetOrCreateBehavior(Control element)
        {
            KeyUpBehavior behavior = element.GetValue(KeyUpBehaviorProperty) as KeyUpBehavior;

            if (behavior == null)
            {
                behavior = new KeyUpBehavior(element);
                element.SetValue(KeyUpBehaviorProperty, behavior);
            }

            return(behavior);
        }
示例#3
0
 public static void SetKeyUpBehavior(DependencyObject obj,
                                     KeyUpBehavior value)
 {
     obj.SetValue(KeyUpBehaviorProperty, value);
 }