WPF Editable ComboBox Text Search Behavior
I have a ComboBox with binded an Entity ObservableCollection on ItemsSource. Like this:
Key Desc1 Desc2
C0001 myDesc myDesc
D0001 myDesc myDesc
A0001 myDesc MyDesc
the combobox is so defined:
<ComboBox
IsEditable=True
DisplayMemberPath="Key"
SelectedValuePath="Key"
ItemsSource="{Binding Path=MyList开发者_StackOverflow中文版, Mode=OneWay}" />
Now I have this problem...
If I type a character on empty editable textbox of combobox, the first element that "startswith" the typed character is matched. So, If I type "C", the selecteditem is the element "C0001"...and I would avoid this!
I would a different search logic that find the selecteditem based on full text typed. In this way:
Text Typed SelectedItem
C null
C0 null
C00 null
C000 null
C0001 [C0001, myDesc, myDesc] OK!
Is possible? How can I do?
This behaviour has always been like this for Combos in Windows. If you want to do something like this, you're probably better off with a search field and a pickable list of results.
Alternatively, the TextBox does support different AutoComplete suggestion modes, but you want a dropdown too I'd imagine. (no, it doesn't).
This post makes a stab at coupling the two up, it's pretty neat.
精彩评论