Defining a Custom Filter Using the ItemFilter Property

If none of the predefined filters suit your needs, the ItemFilter property of the AutoCompleteBox allows you to define a custom method for determining whether a suggestion item matches the entered text. This works well in conjunction with the MVVM pattern, as you see in this section.

To add custom filtering to an AutoCompleteBox, you first create a method that conforms to the AutoCompleteFilterPredicate delegate, shown here:

bool AutoCompleteFilterPredicate<T>(string search, T item)

Your custom filter method must accept a search string (the text entered by the user) and an item from the list of suggestions (usually defined by the ItemsSource property of the AutoCompleteBox), and it must return ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.