AutoSuggestBox.SuggestionChosen 事件

定义

在更新可编辑控件组件的文本内容之前引发。

// 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"/>

事件类型

示例

从建议列表中选择书籍时,将 的文本区域 AutoSuggestBox 设置为书籍的标题:

<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;
}

注解

如果要在控件的可编辑部分显示信息,请响应此事件。 选择建议时更新文本的另一种方法是使用 TextMemberPath 属性。

适用于

另请参阅