共用方式為


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 屬性。

適用於

另請參閱