SearchBoxSuggestionsRequestedEventArgs Klasse

Definition

public ref class SearchBoxSuggestionsRequestedEventArgs sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class SearchBoxSuggestionsRequestedEventArgs final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class SearchBoxSuggestionsRequestedEventArgs final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class SearchBoxSuggestionsRequestedEventArgs
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class SearchBoxSuggestionsRequestedEventArgs
Public NotInheritable Class SearchBoxSuggestionsRequestedEventArgs
Vererbung
Object Platform::Object IInspectable SearchBoxSuggestionsRequestedEventArgs
Attribute

Windows-Anforderungen

Gerätefamilie
Windows 10 (eingeführt in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v1.0)

Beispiele

Wenn Sie asynchron auf das SuggestionsRequested-Ereignis reagieren möchten, müssen Sie ein SearchSuggestionsRequestDeferral-Objekt abrufen, bevor Sie die Vorschlagsliste bearbeiten. Hier ist ein Beispiel, das zeigt, wie das geht.

public async static void SearchBox_SuggestionsRequested(
    SearchBox sender, 
    SearchBoxSuggestionsRequestedEventArgs args)
{

    // This object lets us edit the SearchSuggestionCollection asynchronously. 
    var deferral = args.Request.GetDeferral();

    try { 

        // Retrieve the system-supplied suggestions.
        var suggestions = args.Request.SearchSuggestionCollection;

        var groups = await SampleDataSource.GetGroupsAsync();
        foreach (var group in groups)
        {
            var matchingItems = group.Items.Where(
                item => item.Title.StartsWith(
                    args.QueryText, StringComparison.CurrentCultureIgnoreCase));

            foreach (var item in matchingItems)
            {
                suggestions.AppendQuerySuggestion(item.Title);
            }
        }

        foreach (string alternative in args.LinguisticDetails.QueryTextAlternatives)
        {
            if (alternative.StartsWith(
                args.QueryText, StringComparison.CurrentCultureIgnoreCase))
            {
                suggestions.AppendQuerySuggestion(alternative); 
            }
        }
    }
    finally {
        deferral.Complete();
    }

}

Hinweise

Wichtig

Obwohl SearchBox in der universellen Gerätefamilie implementiert ist, ist es auf mobilen Geräten nicht voll funktionsfähig. Verwenden Sie AutoSuggestBox für Ihre universelle Sucherfahrung. Weitere Informationen finden Sie unter SearchBox als veraltet zugunsten von AutoSuggestBox.

Eigenschaften

Language

Ruft das IETF-Sprachtag (Internet Engineering Task Force) (BCP 47-Standard) ab, das die Sprache identifiziert, die dem Texteingabegerät des Benutzers derzeit zugeordnet ist.

LinguisticDetails

Ruft Informationen zu Abfragetext ab, den der Benutzer über einen Eingabemethoden-Editor (IME) eingibt.

QueryText

Ruft den Abfragetext der aktuellen Suche ab.

Request

Ruft das -Objekt ab, in dem die Vorschläge und Informationen zu dieser Anforderung gespeichert werden.

Gilt für:

Weitere Informationen