-1

When you have several controls, normally you can switch the focus simply by arrow keys. But in my current case this is undesired.

How to disable such focus switching? I already have set TabIndex to -1.

greenoldman
  • 16,895
  • 26
  • 119
  • 185

1 Answers1

0

Handle KeyDown event for the form and set e.Handled = true when the key is Tab. Set KeyPreview = true for the form.

i486
  • 6,491
  • 4
  • 24
  • 41
  • Thank you, but WPF window does not have `KeyPreview` property, and I am not talking about Tab (this is easy), but arrow keys. – greenoldman Nov 13 '14 at 12:46
  • 1
    In WPF there is similar event - add attribute `PreviewKeyDown="Window_PreviewKeyDown"`. I tried this and it disabled left arrow: `private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { Debug.Print("preview {0}", e.Key); if (e.Key == Key.Left) e.Handled = true; }` – i486 Nov 14 '14 at 09:02