SearchPane.SearchHistoryContext 属性

定义

标识搜索上下文的字符串,用于将用户的搜索历史记录与应用一起存储。

public:
 property Platform::String ^ SearchHistoryContext { Platform::String ^ get(); void set(Platform::String ^ value); };
/// [get: 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)]
/// [set: 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)]
winrt::hstring SearchHistoryContext();

void SearchHistoryContext(winrt::hstring value);
/// [get: 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")]
/// [set: 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")]
winrt::hstring SearchHistoryContext();

void SearchHistoryContext(winrt::hstring value);
public string SearchHistoryContext { [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))] get; [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))] set; }
public string SearchHistoryContext { [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")] get; [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")] set; }
var string = searchPane.searchHistoryContext;
searchPane.searchHistoryContext = string;
Public Property SearchHistoryContext As String

属性值

String

Platform::String

winrt::hstring

搜索历史记录上下文字符串。

属性

注解

重要

若要在应用中实现Windows 10或更高版本的搜索,请使用 AutoSuggestBox。 有关详细信息 ,请参阅自动建议框

不应在适用于 Windows 10 或更高版本的应用中使用 Windows.ApplicationModel.Search API (SearchPaneSearchContract) 或 SearchBox API。

注意

应用不能同时使用搜索框 (Windows.UI.Xaml.Controls.SearchBox/WinJS.UI.SearchBox) 和 SearchPane。 在同一应用中同时使用搜索框和搜索窗格会导致应用引发异常,并显示以下消息:“无法创建类型为'Windows.UI.Xaml.Controls.SearchBox'的实例。

搜索历史记录上下文字符串用作存储搜索历史记录的辅助密钥, (主键是 AppId) 。 应用可以使用搜索历史记录上下文字符串来存储基于应用程序上下文的不同搜索历史记录。

如果未设置此属性,Windows 会假定应用中的所有搜索都在同一上下文中进行。 如果在搜索窗格打开且显示建议的情况下更新此属性,则在用户输入下一个字符之前,更改不会生效。

适用于

另请参阅