Dela via


SearchPane.TrySetQueryText(String) Method

Definition

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

public:
 virtual bool TrySetQueryText(Platform::String ^ query) = TrySetQueryText;
/// [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)]
bool TrySetQueryText(winrt::hstring const& query);
/// [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")]
bool TrySetQueryText(winrt::hstring const& query);
[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 bool TrySetQueryText(string query);
[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 bool TrySetQueryText(string query);
function trySetQueryText(query)
Public Function TrySetQueryText (query As String) As Boolean

Parameters

query
String

Platform::String

winrt::hstring

The query text to show in the search pane's search box.

Returns

Boolean

bool

true if the search box text was set successfully; otherwise, false.

Attributes

Remarks

Important

To implement search in an app for Windows 10 or later, use AutoSuggestBox. See Auto-suggest box for more info.

You should not use Windows.ApplicationModel.Search APIs (SearchPane, SearchContract) or SearchBox APIs in apps for Windows 10 or later.

Note

An app can't use both the search box (Windows.UI.Xaml.Controls.SearchBox/WinJS.UI.SearchBox) 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 you have an in-app search box, use this method to maintain consistency between the search pane and your search box. Most apps should reply on the search pane instead of using in-app search UI.

Applies to