AutoSuggestBox.SuggestionChosen Event
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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;
C#
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)
XAML
<AutoSuggestBox SuggestionChosen="eventhandler"/>
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;
}
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.
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 |