question

donpro2009 avatar image
0 Votes"
donpro2009 asked ·

Filter in ComboBox

Hi,
Is it possible to add a filter in a ComboBox?

The ComboBox get its items from a List<T>.

I don't want to enable the IsEditable property, since the user will be able to add anything they want.

I want them to only choose from the items, but since the list can be very long, I want a TextBox that can be used for filtering the items.
At least that's the idea.

Any help is appreciated.

Thanks in advance.

windows-uwpwindows-uwp-xaml
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RoyLi-MSFT avatar image
0 Votes"
RoyLi-MSFT answered ·

Hello,

Welcome to Microsoft Q&A!

Is it possible to add a filter in a ComboBox?

There is no native API in ComboBox that could add a filter in the ComboBox. My suggestion is that you could create a custom control which contains a ComboBox and other controls like Buttons, CheckBoxes, and ListView to show a filter list.

In the custom control, there is a button on right of the ComboBox, then the button is clicked, a Listview contains the keywords for filter and CheckBox in each row. When some keywords are checked, you could filter the itemsource of the ComboBox according to the keywords and show the filtered list in the ComboBox



Besides, I have another suggestion here. Is AutosuggestBox acceptable for you? I noticed that you mentioned you want the customer only to choose. But it is complicated to create a custom control and handle all the logic by yourself. AutoSuggestBox will make suggestions to users as they enter text. You could check the input and show the result as you want by handling TextChanged Event and SuggestionChosen Event.


Thank you.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.