开发者

c# wpf comboBox selecting items in the list when i type the first letter

开发者 https://www.devze.com 2023-02-10 12:40 出处:网络
I have a WPF combobox.It took me ages to figure out how to make it text editable so that some kind of resonable event fires when both the user enters text and when the user picks an option in the list

I have a WPF combobox. It took me ages to figure out how to make it text editable so that some kind of resonable event fires when both the user enters text and when the user picks an option in the list.

I used this method here (very bottom of the page) http://social.msdn.microsoft.com/Forums/en/wpf/thread/13c6dfad-4062-41b9-85d8-0d5f23dd349b

But now I have an issue - if I have an option in the comboBox with the text "Apple" for example and i wish to type "Apricot" into开发者_开发技巧 the field, as soon as I type the letter A it picks Apple from the list. It leaves the caret after the A so I can continue to write Apricot. However due to the way things listen to the comboBox its vital I can prevent this behaviour but have no idea how.

Any help appreciated as always.


ComboBox.IsTextSearchEnabled = false;

Couldn't find that anywhere. Phew


The above solution works in code, below is how I would do it in XAML.

<ComboBox x:Name="cbCountry" IsTextSearchEnabled="False" 
                     LostFocus="cbCountryLostFocus"  KeyUp="cboCountryKeyUp">
0

精彩评论

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

关注公众号