"Win 10 development" about Autosuggestbox

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.