Ejemplo n.º 1
0
        private static void EnterDownCommand_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            var Element = o as FrameworkElement;

            if (Element == null)
            {
                throw new ArgumentException("Type mismatch", "o");
            }

            var Value    = (ICommand)e.NewValue;
            var Listener = GetEnterDownCommandWeakEventListener(Element);

            if (Value != null)
            {
                if (Listener == null)
                {
                    Listener = new EnterDownCommandEventListener();
                }

                SetEnterDownCommandWeakEventListener(Element, Listener);
                PreviewKeyDownEventManager.AddListener(Element, Listener);
            }
            else if (Listener != null)
            {
                SetEnterDownCommandWeakEventListener(Element, null);
                PreviewKeyDownEventManager.RemoveListener(Element, Listener);
            }
        }
        private static void EnterDownCommand_PropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            var Element = o as FrameworkElement;
            if (Element == null)
                throw new ArgumentException("Type mismatch", "o");

            var Value = (ICommand)e.NewValue;
            var Listener = GetEnterDownCommandWeakEventListener(Element);
            if (Value != null)
            {
                if (Listener == null)
                    Listener = new EnterDownCommandEventListener();

                SetEnterDownCommandWeakEventListener(Element, Listener);
                PreviewKeyDownEventManager.AddListener(Element, Listener);
            }
            else if (Listener != null)
            {
                SetEnterDownCommandWeakEventListener(Element, null);
                PreviewKeyDownEventManager.RemoveListener(Element, Listener);
            }
        }