English 中文(简体)
How do I update the ItemsSource for a WPF ComboBox without losing the Text typed into the ComboBox
原标题:

I have a WPF ComboBox (IsEditable = True) that is being populated with items based on the Text entered. I have a property that is bound to ItemsSource. This property is updated in a KeyUp event handler on the ComboBox.

The issue I m having is that when all the text is selected and a new key is pressed - replacing all the highlighted text with a new character - the new character is removed from the ComboBox when the property bound to ItemsSource is updated and I end up with no text. Additional characters entered will stick around.

The end affect is that entering the ComboBox and then typing ab ends up removing the a then searching for b and displaying only b as the Text.

Is there a way to prevent this?

问题回答

It sounds like what you are looking for is AutoComplete functionality.

http://askernest.com/archive/2008/01/23/how-to-make-a-basic-autocomplete-textbox-using-wpf.aspx





相关问题
WPF Datagrid, Setting the background of combox popup

I would like to change the color of the popup background when using a DatagridComboboxColumn in the WPF Toolkit datagrid. I ve edited the Template for a normal Combobox and it works great for selected ...

How to insert ComboBox item into ListBox? [winforms]

The question is very simple, How to insert ComboBox selected item into ListBox using c#? I have tried with this: listbox.Items.Add(combobox.SelectedItem); and some other permutations but it always ...

How do I bind a ComboBox to a one column list

I ve seen how to bind a ComboBox to a list that has columns like this: ItemsSource="{Binding Path=Entries}" DisplayMemberPath="Name" SelectedValuePath="Name" SelectedValue="{Binding Path=Entry}" But ...

Wpf Combobox Limit to List

We are using Wpf Combobox to allow the user to do the following things: 1) select items by typing in the first few characters 2) auto complete the entry by filtering the list 3) suggesting the first ...

热门标签