Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Listbox and keyboard navigation

I have a data-bound ListBox with an ItemTemplate which i want to enable keyboard navigation on.

If i didn't use an item template and just used the DisplayMemberPath then the list would be navigable with the keybaord. Pressing 'G' for example, would set the selected item to the first listitem beginning with G. Using an item template obviously makes that more difficult since there are zero or more textual candidates for such navigation in the template.

My question is how can i either mark an element as the navigation source or mock this effect using other methods?

like image 950
EightyOne Unite Avatar asked Mar 09 '09 10:03

EightyOne Unite


1 Answers

This is possible if you have a textual property that you want to navigate by:

<ListBox TextSearch.TextPath="Name" ... />

Point TextSearch.TextPath at the property you want to enable keyboard-lookup on ("Name" in this example).

like image 178
Matt Hamilton Avatar answered Oct 04 '22 10:10

Matt Hamilton