SearchPane.ResultSuggestionChosen SearchPane.ResultSuggestionChosen SearchPane.ResultSuggestionChosen SearchPane.ResultSuggestionChosen SearchPane.ResultSuggestionChosen Event


Fires when the user selects one of the suggested results that was provided by the app and displayed in the search pane.

public : event TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs> ResultSuggestionChosen
// Register
event_token ResultSuggestionChosen(TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs> const& handler) const;

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

// Revoke with event_revoker
ResultSuggestionChosen_revoker ResultSuggestionChosen(auto_revoke_t, TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs> const& handler) const;
public event TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs> ResultSuggestionChosen
Public Event ResultSuggestionChosen As TypedEventHandler (Of SearchPane, SearchPaneResultSuggestionChosenEventArgs)
function onResultSuggestionChosen(eventArgs){/* Your code */}

searchPane.addEventListener("resultsuggestionchosen", onResultSuggestionChosen);
searchPane.removeEventListener("resultsuggestionchosen", onResultSuggestionChosen);


For C#/C++/VB: This example demonstrates how to ensure that your app can respond to user queries at any time by overriding OnWindowCreated in App.xaml.cs/App.xaml.cpp/App.xaml.vb to access the SearchPane object and register handlers for SearchPane events (like QuerySubmitted and ResultSuggestionChosen).

protected override void OnWindowCreated(WindowCreatedEventArgs args)
    // At window creation time, access the SearchPane object and register SearchPane events
    // (like QuerySubmitted, SuggestionsRequested, and ResultSuggestionChosen) so that the app
    // can respond to the user's search queries at any time.

    // Get search pane
    Windows.ApplicationModel.Search.SearchPane searchPane = SearchSearchPane.GetForCurrentView();
    // Register event handlers for SearchPane events

    // Register QuerySubmitted event handler
    searchPane.QuerySubmitted += new TypedEventHandler<SearchPane, SearchPaneQuerySubmittedEventArgs>(OnQuerySubmitted);
    // Register a SuggestionsRequested if your app displays its own suggestions in the search pane (like from a web service)
    searchPane.SuggestionsRequested += new TypedEventHandler<SearchPane, SearchPaneSuggestionsRequestedEventArgs>(OnSuggestionsRequested);

    // Register a ResultSuggestionChosen if your app displays result suggestions in the search pane
    searchPane.ResultSuggestionChosen += new TypedEventHandler<SearchPane, SearchPaneResultSuggestionChosenEventArgs>(OnResultSuggestionChosen);

For JavaScript: This example demonstrates how to access the searchPane to register a resultsuggestionchosen event handler.


To ensure that your app can respond to user queries at any time, make sure your searchPane event handlers are registered in your app's global scope.

// Register event handler for ResultSuggestionChosen
Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onresultsuggestionchosen = function (eventObject) {
    // Respond when user chooses a result suggestion



An app can't use both the search box (Windows.UI.Xaml.Controls.SearchBox for UWP app using C++, C#, or Visual Basic, WinJS.UI.SearchBox for Windows app using JavaScript) and the SearchPane. Using both the search box and the search pane in the same app causes the app to throw an exception with this message: "Cannot create instance of type 'Windows.UI.Xaml.Controls.SearchBox.'"

If your app participates in the Search contract and displays suggestions for possible results in the search pane, you should register an event handler to respond when this event fires. In your ResultSuggestionChosen event handler, respond by getting the SearchPaneResultSuggestionChosenEventArgs.@Windows.ApplicationModel.Search.SearchPaneResultSuggestionChosenEventArgs.Tag?text=Tag of the chosen result and using it to take the user to the result in your app UI.


If you want to display result suggestions, you must also listen for and handle the SuggestionsRequested event.

See also