你好社区,
我刚开始编写Win8-Metro程序,例如Win8-Store应用程序(C#方式),我正试图通过搜索合同(http://msdn.microsoft.com/en-us/library/windows/apps/hh465231.aspx)编写一个全局即时搜索程序。
即时搜索就像我想要实现的,就像搜索“应用程序”/“应用程序搜索”一样。每个键盘条目都会在搜索窗口中显示新发现的应用程序(搜索魅力文本框下面没有建议),而不按enter键。
在正常情况下,您必须在“搜索结果页”中实现LoadState和Filer_SelectionChanged事件。我想要像在“应用程序”中搜索一样的行为(我知道没有搜索历史!)
如何实现这一目标?有什么例子吗?
发布于 2012-10-02 11:20:04
下面是一个使用搜索契约的示例:http://code.msdn.microsoft.com/windowsapps/Search-app-contract-sample-118a92f5
发布于 2012-10-02 15:25:46
你的问题还不清楚。在即时搜索中,你的意思是在输入时显示结果吗?如果这就是你的意思,我建议你调查一下OnSuggestionsRequested事件。
例如..。
private void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
{
string query = args.QueryText;
string[] terms = { "an item", "Oscillator", "crossbeam", "treddle", "Interossitor", "Spline", "Flange" };
foreach (var term in terms)
{
if (term.StartsWith(query, StringComparison.CurrentCultureIgnoreCase))
{
args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
}
}
}当用户开始键入时,此方法将从您的应用程序中返回一个潜在匹配列表。建议将列在搜索框下面的搜索魅力上。
https://stackoverflow.com/questions/12688941
复制相似问题