示例#1
0
 private void ThisControl_GotFocus(object sender, RoutedEventArgs e)
 {
     if (!Options.IsKeyboardFocusWithin && !TargetLocationSearchTextBox.IsKeyboardFocusWithin && !Flyout.IsKeyboardFocusWithin)
     {
         TargetLocationSearchTextBox.Focus();
     }
 }
示例#2
0
 protected override void OnPreviewKeyDown(KeyEventArgs e)
 {
     if (e.Key == Key.Escape && Flyout.IsOpen)
     {
         TargetLocationSearchTextBox.Focus();
     }
 }
示例#3
0
        private void HandleListBoxKeyPress(object sender, KeyEventArgs e)
        {
            int index = TargetLocationSearchTextBox.CaretIndex;

            switch (e.Key)
            {
            case Key.Tab:
            case Key.Enter:
                CommitSelectionAndMoveFocus();
                e.Handled = true;
                break;

            case Key.Up:
                if (Options.SelectedIndex == 0)
                {
                    SelectedItem = Items[0];
                    LostFocus   -= OnLostFocus;
                    TargetLocationSearchTextBox.Focus();
                    TargetLocationSearchTextBox.CaretIndex = index;
                    LostFocus += OnLostFocus;
                }
                break;

            case Key.Escape:
                Flyout.IsOpen = false;
                TargetLocationSearchTextBox.ScrollToEnd();
                e.Handled = true;
                break;

            case Key.Down:
            case Key.PageDown:
            case Key.PageUp:
            case Key.Home:
            case Key.End:
                break;

            default:
                LostFocus -= OnLostFocus;
                TargetLocationSearchTextBox.Focus();
                TargetLocationSearchTextBox.CaretIndex = index;
                LostFocus += OnLostFocus;
                break;
            }
        }
示例#4
0
        private void HandleListBoxKeyPress(object sender, KeyEventArgs e)
        {
            int index = TargetLocationSearchTextBox.CaretIndex;

            switch (e.Key)
            {
            case Key.Tab:
            case Key.Enter:
                Commit(SelectedItem);
                e.Handled = true;
                TargetLocationSearchTextBox.Focus();
                break;

            case Key.Up:
                if (Options.SelectedIndex == 0)
                {
                    SelectedItem = Items[0];
                    LostFocus   -= OnLostFocus;
                    TargetLocationSearchTextBox.Focus();
                    TargetLocationSearchTextBox.CaretIndex = index;
                    LostFocus += OnLostFocus;
                }
                break;

            case Key.Escape:
                e.Handled = true;
                TargetLocationSearchTextBox.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                break;

            case Key.Down:
            case Key.PageDown:
            case Key.PageUp:
            case Key.Home:
            case Key.End:
                break;

            default:
                LostFocus -= OnLostFocus;
                TargetLocationSearchTextBox.Focus();
                TargetLocationSearchTextBox.CaretIndex = index;
                LostFocus += OnLostFocus;
                break;
            }
        }
示例#5
0
 protected override void OnAccessKey(AccessKeyEventArgs e)
 {
     TargetLocationSearchTextBox.Focus();
 }
示例#6
0
 private void CommitSelectionAndMoveFocus()
 {
     Commit(SelectedItem);
     TargetLocationSearchTextBox.Focus();
 }