How AutoSuggestBox works
mainThe AutoSuggestBox is a text control that provides suggestions to users as they type. It is modeled after WinUI's AutoSuggestBox behavior but adapted for a native look on each platform (iOS, Android, etc.).
To implement a functional search or suggestion experience, you must handle three primary user actions:
- Text changed: Triggered when the user enters text. You use this to update the
ItemsSourcewith filtered data. - Suggestion chosen: Triggered when a user selects an item from the list. You use this to update the text box with the selected item's value.
- Query submitted: Triggered when a user commits a query (e.g., pressing Enter or clicking the query icon). You use this to perform the final search or action.
Key Properties
ItemsSource: The collection of data items to display in the suggestion list.DisplayMemberPath: The name of the property on your data object to show in the suggestion list.TextMemberPath: The name of the property on your data object to automatically populate into the text box when a suggestion is chosen. Usually, this should matchDisplayMemberPath.
<AutoSuggestBox
PlaceholderText="Search"
WidthRequest="200"
TextChanged="AutoSuggestBox_TextChanged"
QuerySubmitted="AutoSuggestBox_QuerySubmitted"
SuggestionChosen="AutoSuggestBox_SuggestionChosen"/>