O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required