AutoSuggestBox.SuggestionChosen 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在可編輯控制群組件的文字內容更新之前引發。
// 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 屬性。