How to move focus using up, down, left and right keys just like a datagrid in WPF? [duplicate]

StackOverflow https://stackoverflow.com/questions/13345222

  •  28-11-2021
  •  | 
  •  

Frage

In my WPF application, I want to move focus to the controls using up, down, left and right keys.

Any ideas?

War es hilfreich?

Lösung

Are you referring to the tab ordering? This means the order in which the focus cycles through your controls when you press TAB or SHIFT-TAB.

The tab ordering in WPF doesn't run in a specific sequence of numbers. Rather, it just checks to see what hte next highest number is. Ie: you could set one control to 0 and one control to 45 and as long there aren't any controls between 0 and 45 then it will jump to 45. To set the order in xaml you add this attached property to your definitions:

<Control KeyboardNavigation.TabIndex="0" />

If you want to exclude controls from the tab order you can:

<control IsTabStop="false"/>

If you'd like to know more information or this doesn't apply to you then can you please supply more detail in your question?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top