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。 有关详细信息 ,请参阅自动建议框

不应在 Windows 10 或更高版本的应用中使用 Windows.ApplicationModel.Search API (SearchPaneSearchContract) 或 SearchBox API。

注意

应用不能同时使用搜索框 (Windows.UI.Xaml.Controls.SearchBox/WinJS.UI.SearchBox) 和 SearchPane。 在同一应用中同时使用搜索框和搜索窗格会导致应用引发异常,并显示以下消息:“无法创建'Windows.UI.Xaml.Controls.SearchBox'类型的实例。”

如果你的应用参与搜索合约并在搜索窗格中显示有关可能结果的建议,则应注册事件处理程序,以便在此事件触发时做出响应。 在 ResultSuggestionChosen 事件处理程序中,通过获取 SearchPaneResultSuggestionChosenEventArgs 进行响应。所选 结果的标记,并使用它来将用户带到应用 UI 中的结果。

注意

如果要显示结果建议,还必须侦听并处理 SuggestionsRequested 事件。

适用于

另请参阅