Sergey K
Sergey K

Reputation: 4114

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

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.

Upvotes: 7

Views: 28506

Answers (2)

TomBot
TomBot

Reputation: 1146

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

Upvotes: 21

icebat
icebat

Reputation: 4774

I think you can resolve your problem by removing IsReadOnly property. You set it to true, so ComboBox doesn`t accept any input. If you don`t want an empty item as a first ComboBox item, you can set SelectedIndex="0".

Upvotes: 1

Related Questions