void AnimationWindow_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Up && !SearchTextBox.IsPopupOpen) { if (CommandsListView.SelectedIndex <= 0) { return; } CommandsListView.SelectedIndex--; } if (e.Key == Key.Down && !SearchTextBox.IsPopupOpen) { CommandsListView.SelectedIndex++; } if (e.Key == Key.Enter && !SearchTextBox.IsPopupOpen) { LauncherCommand command = (LauncherCommand)CommandsListView.SelectedItem; Dispatcher.BeginInvoke((Action)(() => command.Execute(SearchTextBox.Text))); Close(); // Prevents the RecipientEditorControl from receiving this key when we're closing the window e.Handled = true; } if (e.Key == Key.Escape) { if (SearchTextBox.SuppressListForCurrentWord || !SearchTextBox.IsPopupOpen) { Close(); } SearchTextBox.SuppressListForCurrentWord = true; } }