Jaa


SearchBox.QuerySubmitted Event

Definition

Occurs when the user submits a search query.

// Register
event_token QuerySubmitted(TypedEventHandler<SearchBox, SearchBoxQuerySubmittedEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
SearchBox::QuerySubmitted_revoker QuerySubmitted(auto_revoke_t, TypedEventHandler<SearchBox, SearchBoxQuerySubmittedEventArgs const&> const& handler) const;
public event TypedEventHandler<SearchBox,SearchBoxQuerySubmittedEventArgs> QuerySubmitted;
function onQuerySubmitted(eventArgs) { /* Your code */ }
searchBox.addEventListener("querysubmitted", onQuerySubmitted);
searchBox.removeEventListener("querysubmitted", onQuerySubmitted);
- or -
searchBox.onquerysubmitted = onQuerySubmitted;
Public Custom Event QuerySubmitted As TypedEventHandler(Of SearchBox, SearchBoxQuerySubmittedEventArgs) 
<SearchBox QuerySubmitted="eventhandler"/>

Event Type

Examples

Here's a basic XAML definition for a SearchBox, and an implementation of the QuerySubmitted handler. It calls Frame.Navigate to load a search query result page (not shown) that's named SearchResultsPage1. The this/Me reference in the handlers is the containing page instance, as is typical for on-page input event handling code. You can see similar code as part of Quickstart: Adding search to an app and Enabling users to search for information in your .

<SearchBox x:Name="mySearchBox" 
    FocusOnKeyboardInput="True"
    QuerySubmitted="mySearchBox_QuerySubmitted"
    Height="35"  />
private void mySearchBox_QuerySubmitted(SearchBox sender, SearchBoxQuerySubmittedEventArgs args)
{
    this.Frame.Navigate(typeof(SearchResultsPage1), args.QueryText);
}
Private Sub mySearchBox_QuerySubmitted(sender As SearchBox, args As SearchBoxQuerySubmittedEventArgs)
    Me.Frame.Navigate(GetType(SearchResultsPage1), args.QueryText)
End Sub

Remarks

Handle this event so that you can get the QueryText value from SearchBoxQuerySubmittedEventArgs, and pass it on as navigation data when you load a search results page to display to the user.

For a complete example of how to handle QuerySubmitted as part of a complete example that also does search suggestions, see SearchBox control sample.

The handler signature for QuerySubmitted uses TypedEventHandler and enforces that the sender parameter be a SearchBox instance, not just Object.

Applies to

See also