SearchBoxSuggestionsRequestedEventArgs class
TOC
Collapse the table of content
Expand the table of content

SearchBoxSuggestionsRequestedEventArgs class

Provides event data for the SearchBox.SuggestionsRequested event.

Note  Although SearchBox is implemented in the Universal device family, it is not fully functional on mobile devices. Use AutoSuggestBox for your universal search experience. See SearchBox deprecated in favor of AutoSuggestBox.
 

Inheritance

Object
  SearchBoxSuggestionsRequestedEventArgs

Syntax


public sealed class SearchBoxSuggestionsRequestedEventArgs

Members

The SearchBoxSuggestionsRequestedEventArgs class has these types of members:

Methods

The SearchBoxSuggestionsRequestedEventArgs class inherits methods from the Object class.

Properties

The SearchBoxSuggestionsRequestedEventArgs class has these properties.

PropertyAccess typeDescription

Language

Read-only

Gets the Internet Engineering Task Force (IETF) language tag (BCP 47 standard) that identifies the language currently associated with the user's text input device.

LinguisticDetails

Read-only

Gets information about query text that the user enters through an Input Method Editor (IME).

QueryText

Read-only

Gets the query text of the current search.

Request

Read-only

Gets the object that stores the suggestions and information about this request.

 

Remarks

If you want to respond to the SuggestionsRequested event asynchronously, you must obtain a SearchSuggestionsRequestDeferral object before you edit the suggestion list. Here's an example from Quickstart: Adding search to an app that shows how:


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

        }

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1 [Windows Store apps only]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps only]

Minimum supported phone

None supported

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06030000)]
[WebHostHidden()]

See also

Object
SearchBox.SuggestionsRequested

 

 

Show:
© 2016 Microsoft