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.
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.
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.
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.
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.
Try IsTextSearchEnabled="True" TextSearch.TextPath="<PropertyName>"
where <PropertyName>
is a property in the items of your ItemsSource
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With