Consuming keys in SelectionAdapter

Jul 6, 2016 at 12:27 PM
If you press a key like enter in the active selection, the key is bubbled to the window too, e.g. closing the window.

I propose to set Handle to true like:
        public void HandleKeyDown(KeyEventArgs key)
        {
            Debug.WriteLine(key.Key);
            switch (key.Key)
            {
                case Key.Down:
                    key.Handled = true;
                    IncrementSelection();
                    break;
                case Key.Up:
                    key.Handled = true;
                    DecrementSelection();
                    break;
                case Key.Enter:
                    if (Commit != null)
                    {
                        key.Handled = true;
                        Commit();
                    }

                    break;
                case Key.Escape:
                    if (Cancel != null)
                    {
                        key.Handled = true;
                        Cancel();
                    }

                    break;
                case Key.Tab:
                    if (Commit != null)
                    {
                        Commit();
                    }

                    break;
            }
        }