Exemplo n.º 1
0
        private static void CommandProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            Control element = dependencyObject as Control;

            if (element != null)
            {
                PreviewKeyDownBehavior behavior = GetOrCreateBehavior(element);
                behavior.Command = e.NewValue as ICommand;
            }
        }
Exemplo n.º 2
0
        private static PreviewKeyDownBehavior GetOrCreateBehavior(Control element)
        {
            PreviewKeyDownBehavior behavior = element.GetValue(PreviewKeyDownBehaviorProperty) as PreviewKeyDownBehavior;

            if (behavior == null)
            {
                behavior = new PreviewKeyDownBehavior(element);
                element.SetValue(PreviewKeyDownBehaviorProperty, behavior);
            }

            return(behavior);
        }
Exemplo n.º 3
0
 public static void SetPreviewKeyDownBehavior(DependencyObject obj,
                                              PreviewKeyDownBehavior value)
 {
     obj.SetValue(PreviewKeyDownBehaviorProperty, value);
 }