开发者

ComboBox Silverlight

I would like to have the standard silverlightcombobox behave like an html combobox. So let's say I have a combobox for a开发者_如何学Cll 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜