I'm using a ComboBox defined by:
<ComboBox Grid.Column="2" Height="29" HorizontalAlignment="Left" Margin="137,192,0,0" Name="componentsComboBox" VerticalAlignment="Top" Width="224"
IsEditable="True"
TextSearch.TextPath="Name">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
..to display a list of objects by their "Name" properties. I'm observing the following behaviors:
- Click an item in the dropdown, and componentsComboBox.SelectedValue (and .SelectedItem) correspond to the clicked item. OK!
- Start typing the name of an item, autocomplete fills in as you type, .SelectedValue (and .SelectedItem) correspond to the autocompleted item. GREAT!
- Start typing the name of an item, autocomplete fills in as you type, hit delete to truncate to only what you have actually typed, .SelectedValue and .SelectedItem STILL correspond to the autocompleted item. NO! BAD WPF! BAD!
- Similar behavior to 3 if you delete characters from the end of the textbox portion
In essence, if I have a List containing two objects defined by, e.g.,
{ new Component() { Name = "COMPONENT1"},
new Component() { Name = "COMPONENT2"} }
I want the values:
- COMPONENT1
- COMPONENT2
to appear in the drop-down portion, and if the user enters "COMP" I would like to recognize that they have entered a new value, but as it stands right the control makes it look like they selected COMPONENT1.
What am I missing here?