1

我只想显示来自我的应用内搜索的搜索建议,而不是默认出现在 Windows 商店应用程序的 SearchPane 中的建议。搜索窗格中有默认存在的应用程序,我不想在我的应用程序搜索结果中显示它们。

4

1 回答 1

1

在您的搜索页面中,只需添加:

注册事件:

SearchPane.GetForCurrentView().SuggestionsRequested += OnSuggestionsRequested;

处理建议请求事件:

void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
{
    string query = args.QueryText.ToLower();
    string[] terms = { "salt", "pepper", "water", "egg", "vinegar", "flour", "rice", "sugar", "oil" };

    foreach(var term in terms)
    {
        if (term.StartsWith(query))
            args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
    }
}
于 2013-01-11T20:28:38.360 回答