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

            if (element != null)
            {
                KeyDownBehavior behavior = GetOrCreateBehavior(element);
                behavior.Command = e.NewValue as ICommand;
            }
        }
예제 #2
0
        private static KeyDownBehavior GetOrCreateBehavior(Control element)
        {
            KeyDownBehavior behavior = element.GetValue(KeyDownBehaviorProperty) as KeyDownBehavior;

            if (behavior == null)
            {
                behavior = new KeyDownBehavior(element);
                element.SetValue(KeyDownBehaviorProperty, behavior);
            }

            return(behavior);
        }
예제 #3
0
 public static void SetKeyDownBehavior(DependencyObject obj,
                                       KeyDownBehavior value)
 {
     obj.SetValue(KeyDownBehaviorProperty, value);
 }