EightyOne Unite
EightyOne Unite

Reputation: 11805

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?

Upvotes: 9

Views: 2784

Answers (1)

Matt Hamilton
Matt Hamilton

Reputation: 204239

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).

Upvotes: 12

Related Questions