public void Attach(DependencyObject associatedObject)
        {
            AssociatedObject = associatedObject;

            _keysEventArgs = new KeysEventArgs();

            _keydownHandler = UIElement_KeyDown;
            _keyUpHandler   = UIElement_KeyUp;
            Window.Current.Content.AddHandler(UIElement.KeyDownEvent, _keydownHandler, true);
            Window.Current.Content.AddHandler(UIElement.KeyUpEvent, _keyUpHandler, true);
        }
        public void Attach(DependencyObject associatedObject)
        {
            AssociatedObject = associatedObject;

            _keysEventArgs = new KeysEventArgs();

            var uiElement = AssociatedObject as UIElement;

            _keyupEventHandler   = UIElement_KeyUp;
            _keydownEventHandler = UIElement_KeyDown;
            uiElement.AddHandler(UIElement.KeyDownEvent, _keydownEventHandler, true);
            uiElement.AddHandler(UIElement.KeyUpEvent, _keyupEventHandler, true);

            var control = AssociatedObject as Control;

            if (control != null)
            {
                control.IsEnabledChanged += Control_IsEnabledChanged;
            }
        }