Prerequisites-
Now, let's get started with the steps, given below-
Step 1 - Create Windows Universal Project
Open Visual Studio 2015 and click File -> New -> Project Option for New Universal app.
Step 2- Giving the Project Name
New Project Window will open. You can select an Installed -> Template -> Visual C# -> Windows -> Universal and select a Blank App (Universal Windows).
Type Project Name AutoSuggestApp and click OK button.
Step 3 - Setting the platform Versions
Here, we choose the Target Version and Minimum Version for our Universal Windows Application. Click OK button.
Step 4 - Choose Designer Window
Now, we go to the Solution Explorer and open the MainPage.xaml for design.
Step 5 - Designing the App
In the MainPage.xaml designing page, drag the Auto Suggest control from the tool box. Go to Property Window and change the name to Autosuggestcontrol
Next, change the Placeholder Text to search here.
Step 6 - Add the Coding
To add coding, double click on Auto Suggestion Control and add the mentioned source code.
- private string[] Autoitems = new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
- private void Autosuggestcontrol_TextChanged(object sender, SelectionChangedEventArgs e) {
- var Auto = (AutoSuggestBox) sender;
- var Suggestion = Autoitems.Where(p => p.StartsWith(Auto.Text, StringComparison.OrdinalIgnoreCase)).ToArray();
- Auto.ItemsSource = Suggestion;
- }
Step 7 - Run the ApplicationNow, we are ready to run our project. Thus, click the Local Machine to run the Application.
Output Conclusion
I hope, you understood Auto Suggest Box control in Universal Window and how to run it.