SearchSuggestionCollection, classe

SearchSuggestionCollection Class

Représente une collection de propositions de recherche à afficher dans le volet de recherche en réponse à un événement suggestionsrequested.

Syntaxe


var searchSuggestionCollection = searchPaneSuggestionsRequested.searchSuggestionCollection;

Attributs

[MarshalingBehavior(Agile)]
[Muse()]
[Version(0x06020000)]

Membres

SearchSuggestionCollectionClasse possède ces types de membres :

Méthodes

The SearchSuggestionCollection Classe a les méthodes suivantes. Avec C#, Visual Basic et C++, elle hérite également des méthodes de Object Classe.

MéthodeDescription
AppendQuerySuggestion Appends a query suggestion to the list of search suggestions for the search pane.
AppendQuerySuggestions Appends a list of query suggestions to the list of search suggestions for the search pane.
AppendResultSuggestion Appends a suggested search result to the list of suggestions to display in the search pane.
AppendSearchSeparator Appends a text label that is used to separate groups of suggestions in the search pane.

 

Propriétés

Le SearchSuggestionCollectionClasse a les propriétés suivantes.

PropriétéType d'accèsDescription

Size

En lecture seuleThe number of suggestions in the collection.

 

Remarques

Le volet de recherche peut afficher au plus 5 suggestions. En outre, chaque séparateur que vous utilisez remplace une suggestion et diminue le nombre de suggestions que vous pouvez afficher. Pour en savoir plus sur l'affichage des suggestions, consultez Instructions et liste de contrôle pour la recherche.

Une application extrait cet objet via la propriété searchPaneSuggestionsRequest.searchSuggestionCollection lors de la gestion d'un événement suggestionsrequested.

Exemples

L'Exemple de contrat de recherche montre comment répondre à un événement suggestionsrequested, notamment comment utiliser searchSuggestionCollection.


// Register the onsuggestionsrequested event in your apps global scope, for example default.js, so that it is registered as soon as your app is launched.
Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onsuggestionsrequested = function (eventObject) {
    var queryText = eventObject.queryText, suggestionRequest = eventObject.request, linguisticDetails = eventObject.linguisticDetails;

    var queryAlternatives = linguisticDetails.queryTextAlternatives;
    var maxNumberOfSuggestions = 5;
    for (var i = 0, len = queryAlternatives.length, done = false; i < len && !done; i++) {
        // toLowerCase not necessary for East Asian languages. Preserves compatibility when non East Asian suggestions are mixed in with East Asian suggestions.
        var alternative = queryAlternatives[i].toLowerCase();
        for (var j = 0, suggestionLength = suggestionList.length; j < suggestionLength; j++) {
            if (suggestionList[j].substr(0, alternative.length).toLowerCase() === alternative) {
                suggestionRequest.searchSuggestionCollection.appendQuerySuggestion(suggestionList[j]);
                if (suggestionRequest.searchSuggestionCollection.size === maxNumberOfSuggestions) {
                    done = true;
                    break;
                }
            }
        }
    }

    // Construct list of alternatives so we can output them.
    var alternatives = "";
    for (var k = 0, alternativeCount = queryAlternatives.length; k < alternativeCount; k++) {
        alternatives += queryAlternatives[k];
    }
    if (suggestionRequest.searchSuggestionCollection.size > 0) {
        WinJS.log && WinJS.log("Suggestions provided for query: " + queryText + "\nUsing alternatives: " + alternatives, "sample", "status");
    } else {
        WinJS.log && WinJS.log("No suggestions provided for query: " + queryText + "\nUsing alternatives: " + alternatives, "sample", "status");
    }
};


Conditions requises

Client minimal pris en charge

Windows 8 [Applications Windows Store uniquement]

Serveur minimal pris en charge

Windows Server 2012 [Applications Windows Store uniquement]

Espace de noms

Windows.ApplicationModel.Search
Windows::ApplicationModel::Search [C++]

Métadonnées

Windows.winmd

Voir aussi

Exemple de contrat de recherche
Instructions et liste de contrôle pour la recherche
Référence
SearchPane.SuggestionsRequested event
SearchPaneSuggestionsRequestedEventArgs class
SearchPaneSuggestionsRequestedEventArgs.Request property
SearchPaneSuggestionsRequest class
SearchPaneSuggestionsRequest.SearchSuggestionCollection property

 

 

Afficher:
© 2017 Microsoft