共用方式為


SearchPane.ResultSuggestionChosen 事件

定義

當使用者選取應用程式所提供的其中一個建議結果,並在搜尋窗格中顯示時引發。

/// [add: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, Windows.ApplicationModel.Search.SearchContract)]
/// [remove: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, Windows.ApplicationModel.Search.SearchContract)]
// Register
event_token ResultSuggestionChosen(TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
SearchPane::ResultSuggestionChosen_revoker ResultSuggestionChosen(auto_revoke_t, TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs const&> const& handler) const;
/// [add: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.ApplicationModel.Search.SearchContract")]
/// [remove: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.ApplicationModel.Search.SearchContract")]
// Register
event_token ResultSuggestionChosen(TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
SearchPane::ResultSuggestionChosen_revoker ResultSuggestionChosen(auto_revoke_t, TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs const&> const& handler) const;
[add: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, typeof(Windows.ApplicationModel.Search.SearchContract))]
[remove: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, typeof(Windows.ApplicationModel.Search.SearchContract))]
public event TypedEventHandler<SearchPane,SearchPaneResultSuggestionChosenEventArgs> ResultSuggestionChosen;
[add: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.ApplicationModel.Search.SearchContract")]
[remove: Windows.Foundation.Metadata.Deprecated("ISearchPane may be altered or unavailable for releases after Windows 10.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.ApplicationModel.Search.SearchContract")]
public event TypedEventHandler<SearchPane,SearchPaneResultSuggestionChosenEventArgs> ResultSuggestionChosen;
function onResultSuggestionChosen(eventArgs) { /* Your code */ }
searchPane.addEventListener("resultsuggestionchosen", onResultSuggestionChosen);
searchPane.removeEventListener("resultsuggestionchosen", onResultSuggestionChosen);
- or -
searchPane.onresultsuggestionchosen = onResultSuggestionChosen;
Public Custom Event ResultSuggestionChosen As TypedEventHandler(Of SearchPane, SearchPaneResultSuggestionChosenEventArgs) 

事件類型

屬性

備註

重要

若要在應用程式中實作Windows 10或更新版本的搜尋,請使用AutoSuggestBox。 如需詳細資訊 ,請參閱自動建議方塊

您不應該在 app 中使用Windows.ApplicationModel.Search API (SearchPaneSearchContract) 或SearchBox API,以供Windows 10或更新版本使用。

注意

應用程式無法使用搜尋方塊 (Windows.UI.Xaml.Controls.SearchBoxWinJS.UI.SearchBox/) 和 SearchPane。 在相同的應用程式中同時使用搜尋方塊和搜尋窗格,會導致應用程式擲回例外狀況,並顯示下列訊息:「無法建立類型為 'Windows.UI.Xaml.Controls.SearchBox' 的實例」。

如果您的 app 參與搜尋合約,並在搜尋窗格中顯示可能結果的建議,您應該註冊事件處理常式,以在引發此事件時回應。 在 ResultSuggestionChosen 事件處理常式中,取得 SearchPaneResultSuggestionChosenEventArgs來回應。所選結果的標記 ,並用它來將使用者帶至應用程式 UI 中的結果。

注意

如果您想要顯示結果建議,您也必須接聽並處理 SuggestionsRequested 事件。

適用於

另請參閱