I have a ComboBox in my WPF App, that I want to enter Text in, which is used to update the Content (Items) of the ComboBox.
Whenever I enter a character, I want the updated Items to show. So I set IsDropDownOpen = true;
, but this causes the Text which was entered to be selected.
The result is: I type 1 char, the ComboBox DropDown is opened (and shows new Items), the char gets selected. I type a second char and it replaces the first one, because it was selected (duh)!
How can I deselect all Text in the ComboBox? I obviously want to type more than 1 char whithout having to click on the ComboBox again to deselect all text...
Code:
//MainWindow.xaml
<ComboBox x:Name="comboBoxItemID" HorizontalAlignment="Left" Height="38"
VerticalAlignment="Top" Width="300" Canvas.Left="197" FontSize="21.333"
IsEnabled="True" KeyUp="comboBoxItemID_KeyUp" IsEditable="True"/>
//comboBoxItemID_KeyUp()
List<InventorySearchResult> Items = Invent.SearchArticle(this.comboBoxItemID.Text); //Get new Data
comboBoxItemID.ItemsSource = Items; //Update comboBox Data
comboBoxItemID.DisplayMemberPath = "Name";
comboBoxItemID.IsDropDownOpen = true;
Invent.SearchArticle()
actually performs a SQL Query, the returnedList<InventorySearchResult>
is a list of Rows returned by that query. Or should I declare a List, that that as ItemsSource once, and only change that list's contents? – NoMad