Fires when the user submits the text in the search box and the app needs to display search results.
Syntax
function onQuerySubmitted(eventArgs) { /* Your code */ } // addEventListener syntax searchPane.addEventListener("querysubmitted", onQuerySubmitted); searchPane.removeEventListener("querysubmitted", onQuerySubmitted); - or - searchPane.onquerysubmitted = onQuerySubmitted;
Event information
| Delegate | TypedEventHandler(SearchPane, SearchPaneQuerySubmittedEventArgs) |
|---|
Remarks
If your app participates in the Search contract, register an event handler to respond when this event fires. In your QuerySubmitted event handler, respond by taking the user to your search results page and populating it with results based on the SearchPaneQuerySubmittedEventArgs.QueryText.
Examples
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).
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) // Register a ResultSuggestionChosen if your app uses result suggestions in the search pane }
For JavaScript: This example demonstrates how to access the searchPane to register a querysubmitted event handler.
Note 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 QuerySubmitted Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onquerysubmitted = function (eventObject) { // Respond to query and perform search };
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Namespace |
|
|
Metadata |
|
See also
- Search contract sample
- Reference
- SearchPane class
- SearchPane.QueryChanged event
- SearchPaneQuerySubmittedEventArgs class
Build date: 12/4/2012