Filter in ComboBox

Preveen 216 Reputation points
2020-06-18T23:48:03.81+00:00

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.

Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 33,366 Reputation points Microsoft Vendor
    2020-06-19T03:16:50.49+00:00

    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.