Skip to main content

Open-WebUI-Functions is here! New Pipelines, Filters, and more. Learn more

WinUI ComboBox Filtering

ComboBox combines a non-editable text box with a drop-down list so users can quickly select from a curated set of items. The examples below show how to enable incremental filtering and keep the control accessible for touch, keyboard, and screen reader scenarios.

Learn more

Overview

  • Use ItemsSource bindings for dynamic data so the control updates automatically when your view model changes.
  • Set IsEditable="True" to enable inline search while still preventing arbitrary user input from being committed unless it matches a known entry.
  • Pair with SelectionChanged events or SelectedItem bindings to react to user choices in view models.

Prerequisites

  • WinUI 3 project targeting Windows 10 version 1809 (build 17763) or later
  • View model exposing an ObservableCollection<T> or ICollectionView
  • Localization strategy for the items if you support multiple languages

Add incremental filtering

If a ComboBox contains many items, surface search to keep the dropdown manageable. The pattern below filters items while preserving the original collection.

filtered-combobox

For large datasets, consider virtualized sources like CollectionViewSource or a predictive search service so the filtering logic remains responsive.

Here is the corresponding XAML and code-behind:

Keyboard navigation support

  • Handle TextSubmitted and SelectionChanged together so users can commit entries with Enter while maintaining arrow key navigation.
  • Enable IsTextSearchEnabled="True" when using simple lists to let WinUI auto-select items as the user types.
  • When IsEditable="True", keep the placeholder text descriptive so screen readers announce the expected input.

Best practices

  • Validation: Reject values that do not exist in your backing collection to keep data consistent. Provide a TeachingTip or inline validation message when rejecting input.
  • Performance: Debounce filter logic or use a timer when your source is remote to avoid spamming network requests.
  • Styling: Use ItemsPresenter templates to highlight matching substrings when filtering so users can see why an item was returned.

Troubleshooting

  • Dropdown closes unexpectedly: Ensure you are not updating the bound collection on the UI thread while the popup is open; batch updates or use DeferRefresh.
  • Scroll position resets: Cache the ScrollViewer inside the ComboBox template and restore ChangeView after filter operations.
  • VoiceOver/Narrator repeats items: Set AutomationProperties.Name for custom item templates and keep visual children simple.