Windows Dev Center

SearchPaneSuggestionsRequest Class

Stocke des suggestions et des informations sur la demande de suggestions.

Syntaxe


var searchPaneSuggestionsRequest = searchPaneSuggestionsRequestedEventArgs.request;

Attributs

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

Membres

SearchPaneSuggestionsRequestClasse possède ces types de membres :

Méthodes

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

MéthodeDescription
GetDeferral Retrieves an object that lets an app respond to a request for suggestions asynchronously.

 

Propriétés

Le SearchPaneSuggestionsRequestClasse a les propriétés suivantes.

PropriétéType d'accèsDescription

IsCanceled

En lecture seuleIndicates whether the request for suggestions to display is canceled.

SearchSuggestionCollection

En lecture seuleThe suggestions to display in the search pane for the current query. Apps provide suggestions to display by appending them to this searchSuggestionCollection object.

 

Remarques

Si votre application présente ses propres suggestions à afficher dans le volet de recherche, utilisez la propriété searchPaneSuggestionsRequest.searchSuggestionCollection pour ajouter les suggestions de votre application à la collection des suggestions à afficher.

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.

Exemples

L'Exemple de contrat de recherche montre comment répondre à un événement suggestionsrequested, notamment comment accéder à searchPaneSuggestionsRequest.


Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onsuggestionsrequested = function (eventObject) {
    var queryText = eventObject.queryText, language = eventObject.language, suggestionRequest = eventObject.request;

    // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service.
    // Indicate that we'll do this asynchronously:
    var deferral = suggestionRequest.getDeferral();

    // Use the web service Uri entered in the urlInput that supports this standard in order to see suggestions come from the web service.
    // See http://msdn.microsoft.com/en-us/library/cc848863(v=vs.85).aspx for details on XML Search Suggestions format.
    // And replace "{searchTerms}" with the query string, which should be encoded into the URI.
    var suggestionUri = document.getElementById("urlInput").innerText.replace("{searchTerms}", encodeURIComponent(queryText));

    // Cancel the previous suggestion request if it is not finished.
    if (xhrRequest && xhrRequest.cancel) {
        xhrRequest.cancel();
    }

    // Create request to obtain suggestions from service and supply them to the Search Pane.
    xhrRequest = WinJS.xhr({ url: suggestionUri });
    xhrRequest.done(
        function (request) {
            if (request.responseXML) {
                generateSuggestions(request.responseXML, suggestionRequest.searchSuggestionCollection, queryText);
            }

            deferral.complete(); // Indicate we're done supplying suggestions.
        },
        function (error) {
            WinJS.log && WinJS.log("Error retrieving suggestions for query: " + queryText, "sample", "status");

            // Call complete on the deferral when there is an error.
            deferral.complete();
        });
};


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

Référence
Exemple de contrat de recherche
SearchPane.SuggestionsRequested event
SearchPaneSuggestionsRequestedEventArgs class
SearchPaneSuggestionsRequestedEventArgs.Request property

 

 

Afficher:
© 2015 Microsoft