SearchPane SearchPane SearchPane SearchPane SearchPane Class


Deprecated. Use the Windows.UI.Xaml.Controls.SearchBox (XAML) or the WinJS.UI.SearchBox (HTML) control instead. Represents and manages the search pane that opens when a user activates the Search charm.


An app can't use both the search box (Windows.UI.Xaml.Controls.SearchBox for XAMLUniversal Windows Platform (UWP) app, WinJS.UI.SearchBox for HTMLUniversal Windows Platform (UWP) app) 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.'"

public : sealed class SearchPane : ISearchPane
struct winrt::Windows::ApplicationModel::Search::SearchPane : ISearchPane
public sealed class SearchPane : ISearchPane
Public NotInheritable Class SearchPane Implements ISearchPane
// This class does not provide a public constructor.
Windows 10 requirements
Device family
Windows Desktop Extension SDK (introduced v10.0.10240.0) Xbox One Extensions for the UWP (introduced v10.0.10586.0)
API contract
Windows.ApplicationModel.Search.SearchContract (introduced v1)


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.


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


This object is available to apps that participate in the Search contract; you can learn more about adding the Search contract to your app in Quickstart: Adding search. In order to provide users with search results, you must add code to your activated event handler that responds when your app is activated for search. To learn more about responding to search activation events see webUISearchActivatedEventArgs (JavaScript) or SearchActivatedEventArgs (C#/C++/VB).

You can see code examples that demonstrate how to respond to search events and manage the search pane in the Search contract sample.


Language Language Language Language Language

The Internet Engineering Task Force (IETF) language tag (BCP 47 standard) that identifies the language currently associated with the user's text input device.

PlaceholderText PlaceholderText PlaceholderText PlaceholderText PlaceholderText

The placeholder text in the search box when the user hasn't entered any characters.

QueryText QueryText QueryText QueryText QueryText

The current text in the search box of the search pane.

SearchHistoryContext SearchHistoryContext SearchHistoryContext SearchHistoryContext SearchHistoryContext

A string that identifies the context of the search and is used to store the user's search history with the app.

SearchHistoryEnabled SearchHistoryEnabled SearchHistoryEnabled SearchHistoryEnabled SearchHistoryEnabled

Indicates whether the user's previous searches with the app are automatically tracked and used to provide suggestions.

ShowOnKeyboardInput ShowOnKeyboardInput ShowOnKeyboardInput ShowOnKeyboardInput ShowOnKeyboardInput

Gets or sets whether the user can open the search pane by typing.

Visible Visible Visible Visible Visible

Indicates whether the search pane is open.


GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView()

Retrieves an instance of the search pane from which users can search within the app.

HideThisApplication() HideThisApplication() HideThisApplication() HideThisApplication() HideThisApplication()

Hides the current app's UI.

SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SetLocalContentSuggestionSettings(LocalContentSuggestionSettings) SetLocalContentSuggestionSettings(LocalContentSuggestionSettings)

Specifies whether suggestions based on local files are automatically displayed in the search pane, and defines the criteria that Windows uses to locate and filter these suggestions.

Show() Show() Show() Show() Show()

Shows the search pane.

Show(String) Show(String) Show(String) Show(String) Show(String)

Shows the search pane with the specified initial query string.

TrySetQueryText(String) TrySetQueryText(String) TrySetQueryText(String) TrySetQueryText(String) TrySetQueryText(String)

Attempts to set the text in the search box of the search pane.


QueryChanged QueryChanged QueryChanged QueryChanged QueryChanged

Fires when the user changes the text in the search box.

QuerySubmitted QuerySubmitted QuerySubmitted QuerySubmitted QuerySubmitted

Fires when the user submits the text in the search box and the app needs to display search results.

ResultSuggestionChosen ResultSuggestionChosen ResultSuggestionChosen ResultSuggestionChosen ResultSuggestionChosen

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

SuggestionsRequested SuggestionsRequested SuggestionsRequested SuggestionsRequested SuggestionsRequested

Fires when the user's query text changes and the app needs to provide new suggestions to display in the search pane.

VisibilityChanged VisibilityChanged VisibilityChanged VisibilityChanged VisibilityChanged

Fires when the user opens or closes the search pane.

See Also