AutoSuggestBox.SuggestionChosen Event

Definition

Raised before the text content of the editable control component is updated.

C#
public event TypedEventHandler<AutoSuggestBox,AutoSuggestBoxSuggestionChosenEventArgs> SuggestionChosen;
XAML
<AutoSuggestBox SuggestionChosen="eventhandler"/>

Event Type

Examples

When a book is chosen from a suggestion list, set the text area of AutoSuggestBox to the book's title:

XAML
<AutoSuggestBox  
    ItemsSource="{x:Bind Books}"
    SuggestionChosen="AutoSuggestBox_SuggestionChosen" 
    UpdateTextOnSelect="True" />
cs
private void AutoSuggestBox_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
{
    var book = args.SelectedItem as Book;
    sender.Text = book.Title;
}

Remarks

Respond to this event when you want to display information in the editable part of the control. An alternative way of updating the text when a suggestion is chosen is to use the TextMemberPath property.

Applies to

Product Versions
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

See also