Gabe
Gabe

Reputation: 50483

ComboBox Silverlight

I would like to have the standard silverlightcombobox behave like an html combobox. So let's say I have a combobox for all states in the US, If I press the 'I' key, it should navigate the selected item to start at the I's ... Is there anyway to do this, it doesn't make sense that it's not built in functionality.

Maybe I missed the memo? Any ideas?

Upvotes: 1

Views: 388

Answers (1)

ChrisF
ChrisF

Reputation: 137128

It's not something that comes as standard - even in Silverlight 4 (I hit this very problem today).

However, there are quite a few DIY implementations on the net:

http://gistom.blogspot.com/2009/12/silverlight-combobox-with-keyboard.html

http://www.codeproject.com/KB/silverlight/ComboBoxKeyBrdSelection.aspx

http://www.reflectionit.nl/Blog/PermaLinkd137c1f7-a515-4084-8199-f8b3cf892b8f.aspx

The author of the last post

created a small Behavior which fixes this problem. You can attach the KeyboardSelectionBehavior to a ListBox or ComboBox using Microsoft Expression Blend. You drag it from the Assets and drop it on your ComboBox or ListBox. If you have a custom ItemTemplate you will have to set the SelectionMemberPath property.

If you don't have access to Blend then just use the code as a template and edit the XAML by hand to produce the same result.

Upvotes: 1

Related Questions