public override bool OnKeyDown(KeyboardKeyEventArgs e) { if (base.OnKeyDown(e)) { return(true); } if (!IsFocused) { return(false); } ComboBoxBase parent = Parent as ComboBoxBase; if (parent == null) { return(false); } bool handled = false; switch (e.Key) { case Key.Up: SeekIndex(SelectedIndex - 1); return(true); case Key.Down: SeekIndex(SelectedIndex + 1); return(true); case Key.PageUp: SeekIndex(SelectedIndex - (int)(Bounds.Height / parent.ItemHeight)); return(true); case Key.PageDown: SeekIndex(SelectedIndex + (int)(Bounds.Height / parent.ItemHeight)); return(true); case Key.Home: SeekIndex(0); return(true); case Key.End: SeekIndex(parent.Count - 1); return(true); case Key.Enter: if (SelectedIndex >= 0 && SelectedIndex < parent.Count) { OnItemSelected(); OnClose(); return(true); } break; case Key.Escape: OnClose(); return(true); } return(handled); }