SearchBoxSuggestionsRequestedEventArgs
SearchBoxSuggestionsRequestedEventArgs
SearchBoxSuggestionsRequestedEventArgs
SearchBoxSuggestionsRequestedEventArgs
Class
Definition
Provides event data for the SearchBox.SuggestionsRequested event.
public : sealed class SearchBoxSuggestionsRequestedEventArgs : ISearchBoxSuggestionsRequestedEventArgspublic sealed class SearchBoxSuggestionsRequestedEventArgs : ISearchBoxSuggestionsRequestedEventArgsPublic NotInheritable Class SearchBoxSuggestionsRequestedEventArgs Implements ISearchBoxSuggestionsRequestedEventArgs// This API is not available in Javascript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
Examples
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 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();
}
}
Remarks
Important
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.
Properties
Language Language Language Language
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.
public : PlatForm::String Language { get; }public string Language { get; }Public ReadOnly Property Language As string// This API is not available in Javascript.
- Value
- PlatForm::String string string string
The IETF BCP 47 standard language tag.
LinguisticDetails LinguisticDetails LinguisticDetails LinguisticDetails
Gets information about query text that the user enters through an Input Method Editor (IME).
public : SearchQueryLinguisticDetails LinguisticDetails { get; }public SearchQueryLinguisticDetails LinguisticDetails { get; }Public ReadOnly Property LinguisticDetails As SearchQueryLinguisticDetails// This API is not available in Javascript.
- Value
- SearchQueryLinguisticDetails SearchQueryLinguisticDetails SearchQueryLinguisticDetails SearchQueryLinguisticDetails
Linguistic information about query text that the user enters through an Input Method Editor (IME).
QueryText QueryText QueryText QueryText
Gets the query text of the current search.
public : PlatForm::String QueryText { get; }public string QueryText { get; }Public ReadOnly Property QueryText As string// This API is not available in Javascript.
- Value
- PlatForm::String string string string
The query text of the current search.
Request Request Request Request
Gets the object that stores the suggestions and information about this request.
public : SearchSuggestionsRequest Request { get; }public SearchSuggestionsRequest Request { get; }Public ReadOnly Property Request As SearchSuggestionsRequest// This API is not available in Javascript.
- Value
- SearchSuggestionsRequest SearchSuggestionsRequest SearchSuggestionsRequest SearchSuggestionsRequest
The object that stores the suggestions and information about this request.
- See Also