Editable ComboBox without Text Search

时间:2017-06-15 10:32:09

标签: c# wpf mvvm combobox textbox

I have an editable combobox:

<ComboBox IsEditable="True" IsTextSearchEnabled="False"  Grid.Row="3" Grid.Column="2">
    <ComboBox.Style>
        <Style TargetType="{x:Type ComboBox}">
            <Setter Property="Background" Value="Wheat"/>
        </Style>
    </ComboBox.Style>
    <ComboBox.Items> 
        <ComboBoxItem Content="a"/> 
        <ComboBoxItem Content="f"/>
        <ComboBoxItem Content="v"/>
    </ComboBox.Items>
</ComboBox>

I can select things from the list and I can write custom text (for example 'R').

When I put false in IsTextSearchEnabled the selected index does not work properly.

i.e. when I write a value that is not in the list, the selected index does not change to -1.

Also, when I write a value in the list, the correct index is not selected, but remains in the previous index.

On the other hand, I'm not interested in TextSearch's behavior.

How can I disable the TextSearch behavior without affecting the behavior of the selected index?

0 个答案:

没有答案