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

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

            var Value    = (bool)e.NewValue;
            var Listener = GetProcessEnterAsTabWeakEventListener(Element);

            if (Value)
            {
                if (Listener == null)
                {
                    Listener = new ProcessEnterAsTabEventListener();
                }

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

            var Value = (bool)e.NewValue;
            var Listener = GetProcessEnterAsTabWeakEventListener(Element);
            if (Value)
            {
                if (Listener == null)
                    Listener = new ProcessEnterAsTabEventListener();

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