Actually look at the name we know, this control can provide some suggestions text. When we do the search box, we can do some text to let the user choose.
This control has two key event querysubmitted and Suggestionchosen events, and the Suggestionchosen event occurs when an item in the drop-down list is selected. When you make a selection in the drop-down list, the input text is submitted, and the Querysubmitted event occurs, and the query text to be submitted in the input box is obtained from the QueryText property of the event argument.
Let's make a small example of querying a word, and look at the XAML layout first.
1 <StackPanelHorizontalAlignment= "Center"Width= "The ">2 <AutosuggestboxName= "Search"Queryicon= "Find"Placeholdertext= "Please enter a word"3 querysubmitted= "search_querysubmitted"Suggestionchosen= "Search_suggestionchosen">4 </Autosuggestbox>5 <TextBlockName= "Content"FontSize= "Max"Foreground= "LightBlue"/>6 </StackPanel>
Next, we set the drop-down list for the Autosuggestbox control and use the ItemsSource property to specify the data source.
string[] array = new string[] { "auto", "suggest", "Search", "page", "Surface", "Microsoft", "Keyboard", "Help" }; ... Search. ItemsSource = array;
Handling Suggestionchosen Events
1 Private void Search_suggestionchosen (Windows.UI.Xaml.Controls.AutoSuggestBox sender, Autosuggestboxsuggestionchoseneventargs args)2 {3 string as string ; 4 Sender. Text = s; 5 }
Handling querysubmitted Events
Private void search_querysubmitted (Windows.UI.Xaml.Controls.AutoSuggestBox sender, Autosuggestboxquerysubmittedeventargs args) { = $"{args. QueryText}"; }
At this point, this small example is complete.
"Win 10 development" about Autosuggestbox