Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make that WPF ComboBox keyboard text search will works correctly if IsEditable and IsReadOnly is true?

Tags:

c#

wpf

Hello every one I have a problem with WPF ComboBox look at the code

<ComboBox x:Name="comboBox" Width="100" IsReadOnly="True" IsEditable="True" IsTextSearchEnabled="True">
<ComboBoxItem>dsf gd</ComboBoxItem>
<ComboBoxItem>asf gd</ComboBoxItem>
<ComboBoxItem>dsf gd</ComboBoxItem>
<ComboBoxItem>hsf gd</ComboBoxItem>
</ComboBox>

requirement is that the text in ComboBox can be selected, text search by key first letter shold work, and the comboBox should be editable I set the properties

IsReadOnly="True" 
IsEditable="True"

but Text search doesn't work. Help me resolve this issue, please. Thanks in advance.

like image 988
Serghei Avatar asked Nov 02 '11 11:11

Serghei


People also ask

How do I make a ComboBox not editable?

To make the text portion of a ComboBox non-editable, set the DropDownStyle property to "DropDownList". The ComboBox is now essentially select-only for the user. You can do this in the Visual Studio designer, or in C# like this: stateComboBox.

How do I change the ComboBox style in WPF?

In visual studio, open WPF designer, select combo box control, then right click combo box control and select Edit template, then select Edit a Copy. This will create a style template, you can modify it as you need.

How do I add a ComboBox item in WPF?

On button click event handler, we add the content of TextBox to the ComboBox by calling ComboBox. Items. Add method. Now if you enter text in the TextBox and click Add Item button, it will add contents of the TextBox to the ComboBox.

What is ComboBox WPF?

A combobox is a selection control that combines a non-editable textbox and a drop-down listbox that allows users to select an item from a list. It either displays the current selection or is empty if there is no selected item.


1 Answers

Try IsTextSearchEnabled="True" TextSearch.TextPath="<PropertyName>" where <PropertyName> is a property in the items of your ItemsSource.

like image 55
TomBot Avatar answered Dec 07 '22 12:12

TomBot