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
  •  | 
  •  

Domanda

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

Any ideas?

È stato utile?

Soluzione

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?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top