SearchBoxSuggestionsRequestedEventArgs クラス

定義

SearchBox.SuggestionsRequested イベントのイベント データを提供します。

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
継承
Object Platform::Object IInspectable SearchBoxSuggestionsRequestedEventArgs
属性

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

SuggestionsRequested イベントに非同期的に応答する場合は、提案リストを編集する前に SearchSuggestionsRequestDeferral オブジェクトを取得する必要があります。 その方法を示す例を次に示します。

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();
    }

}

注釈

重要

ユニバーサル デバイス ファミリでは SearchBox が実装されていますが、モバイル デバイスでは部分的に機能しません。 ユニバーサル検索エクスペリエンスには AutoSuggestBox を使います。 「AutoSuggestBox に使用されない SearchBox」をご覧ください。

プロパティ

Language

ユーザーのテキスト入力デバイスに現在関連付けられている言語を識別するインターネット エンジニアリング タスク フォース (IETF) 言語タグ (BCP 47 標準) を取得します。

LinguisticDetails

ユーザーが入力メソッド エディター (IME) を使用して入力したクエリ テキストに関する情報を取得します。

QueryText

現在の検索のクエリ テキストを取得します。

Request

この要求に関する提案と情報を格納する オブジェクトを取得します。

適用対象

こちらもご覧ください