Dela via


AutoSuggestBox.SuggestionChosen Event

Definition

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

// Register
event_token SuggestionChosen(TypedEventHandler<AutoSuggestBox, AutoSuggestBoxSuggestionChosenEventArgs const&> const& handler) const;

// Revoke with event_token
void SuggestionChosen(event_token const* cookie) const;

// Revoke with event_revoker
AutoSuggestBox::SuggestionChosen_revoker SuggestionChosen(auto_revoke_t, TypedEventHandler<AutoSuggestBox, AutoSuggestBoxSuggestionChosenEventArgs const&> const& handler) const;
public event TypedEventHandler<AutoSuggestBox,AutoSuggestBoxSuggestionChosenEventArgs> SuggestionChosen;
function onSuggestionChosen(eventArgs) { /* Your code */ }
autoSuggestBox.addEventListener("suggestionchosen", onSuggestionChosen);
autoSuggestBox.removeEventListener("suggestionchosen", onSuggestionChosen);
- or -
autoSuggestBox.onsuggestionchosen = onSuggestionChosen;
Public Custom Event SuggestionChosen As TypedEventHandler(Of AutoSuggestBox, AutoSuggestBoxSuggestionChosenEventArgs) 
<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:

<AutoSuggestBox  
    ItemsSource="{x:Bind Books}"
    SuggestionChosen="AutoSuggestBox_SuggestionChosen" 
    UpdateTextOnSelect="True" />
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

See also