Achieve Google-Like Autosuggestions with the WinUI AutoComplete Control
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (180).NET Core  (28).NET MAUI  (224)Angular  (113)ASP.NET  (49)ASP.NET Core  (81)ASP.NET MVC  (87)Azure  (41)Black Friday Deal  (1)Blazor  (234)BoldSign  (14)DocIO  (24)Essential JS 2  (110)Essential Studio  (199)File Formats  (72)Flutter  (135)JavaScript  (226)Microsoft  (121)PDF  (83)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (960)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (46)Webinar  (53)Windows Forms  (59)WinUI  (72)WPF  (162)Xamarin  (159)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (10)Business intelligence  (55)Button  (4)C#  (163)Chart  (145)Chart of the week  (57)Cloud  (15)Company  (440)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (73)Development  (676)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (13)Excel  (43)Extensions  (23)File Manager  (7)Gantt  (20)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (519)Mobile MVC  (9)OLAP server  (2)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (45)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (8)Reporting / Back Office  (9)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (5)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (32)Solution Services  (4)Spreadsheet  (11)SQL  (15)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (113)UI  (400)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (624)What's new  (337)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Achieve Google-Like Autosuggestions with the WinUI AutoComplete Control

Achieve Google-Like Autosuggestions with the WinUI AutoComplete Control

The Syncfusion WinUI AutoComplete loads and populates data in a suggestion list depending on the user’s input characters. Users can then select one or more items from the list. Items selected from the list can be displayed with images, text, and close buttons to remove them as needed.

Key features

The key features of the WinUI AutoComplete control are as follows:

  • Smoothly and dynamically presents items based on the user input.
  • Does not include a dropdown button. When a user types, the dropdown automatically opens with suggestions.
  • Handles a huge volume of data and shows suggestions based on logical matching instead of just string comparison.
  • Also supports filtering, grouping, appearance customization, and more.

The best example of AutoComplete control is a search engine. When you search for something, suggestions are listed based on popular queries by other users.

In this blog, we will see how to achieve Google-like autosuggestions in a WinUI application using our AutoComplete control.

Google-like autosuggestions using the WinUI AutoComplete control

Let’s fetch suggestions from the Google search engine and show them using the WinUI AutoComplete control.

Google-Like Autosuggestions Using WinUI AutoComplete Control
Google-Like Autosuggestions Using WinUI AutoComplete Control

Step #1: Adding the WinUI AutoComplete control to your application

Follow these steps to add the AutoComplete control to the XAML page of your WinUI app:

  1. First, create a WinUI 3 desktop app for C# and .NET 5.
  2. Then, download and install the Syncfusion.Editors.WinUI NuGet package in the project.
  3. Now, import the control namespace Syncfusion.UI.Xaml.Editors on the XAML page.
  4. Initialize the WinUI AutoComplete control. Refer to the following code example.
       xmlns:local="using:WinUI_Calendar "
       <editors:SfAutoComplete Width="300"/>

Step #2: Get suggestions from the Google search engine based on user input

When we search for something in a search engine, we will get suggestions based on our input characters. Let’s see how to fetch suggestions from the Google search engine.

Refer to the following code to fetch suggestions as an XML document. Here, the query refers to the user’s input.

string xmlSuggestions;
using (HttpClient client = new HttpClient())
  var searchQuery = "" + query;
  xmlSuggestions = client.GetStringAsync(searchQuery);

Let’s say we are trying to search for information about today’s weather, so we’ll use the partial input how is the wea. This will give us the following search query:

This query will give the following suggestions:

   <suggestion data="how is the weather today"/>
   <suggestion data="how is the weather"/>
   <suggestion data="how is the weather tomorrow"/>
   <suggestion data="how is the weather going to be tomorrow"/>
   <suggestion data="how is the weather outside"/>
   <suggestion data="how is the weather in new york"/>
   <suggestion data="how is the weather in spanish"/>
   <suggestion data="how is the weather tonight"/>
   <suggestion data="how is the weather in chicago"/>
   <suggestion data="how is the weather in florida"/>

Step #3: Parse the XML document and get the suggestions

With the suggestions in hand as an XML document, we need to parse it and get the required data. Once the data is collected, we return the accumulated data as a list.

Refer to the following code.

XDocument doc = XDocument.Parse(xmlSuggestions);
var suggestions = doc.Descendants("CompleteSuggestion")
    item => item.Element("suggestion").Attribute("data").Value);
return suggestions.ToList();

Step #4: Show suggestions using WinUI AutoComplete based on user input

Now that we know how to get suggestions from the Google search engine based on the user input characters. Let’s see how to implement this in the WinUI AutoComplete control.

When a user provides input in the AutoComplete control, the FilterBehavior property will populate the suggestions. It is of type IAutoCompleteFilterBehavior.

Create the CustomFiltering class to implement the IAutoCompleteFilterBehavior interface. The GetMatchingItemsAsync method will be called whenever a user starts typing. Then, the items that are returned by this method will be shown as suggestions in the dropdown.

Refer to the following code example.

public class CustomFiltering : IAutoCompleteFilterBehavior
  public Task<object> GetMatchingItemsAsync(SfAutoComplete source, AutoCompleteFilterInfo filterInfo)
    var result = GetGoogleSuggestions(filterInfo.Text);
    return Task.FromResult((object)result);
  private IList<string> GetGoogleSuggestions(string query)
    // Get suggestions using the Google search query.
<editors:SfAutoComplete HorizontalAlignment="Center"
                        PlaceholderText="Search something"
Google-Like Autosuggestions Using WinUI AutoComplete Control
Google-Like Autosuggestions Using WinUI AutoComplete Control

That’s all there is to it!

GitHub demo

You can download a working example of Google-like autosuggestions using WinUI AutoComplete control from GitHub.


Thanks for reading! In this blog post, we have seen how to implement Google-like autosuggestions using the Syncfusion WinUI AutoComplete control. For more details, refer to the WinUI AutoComplete documentation and demo app in the Windows Store. Try out the procedure in this blog post and leave your feedback in the comments section below.

For existing customers, the newest version of Essential Studio is available for download from the license and downloads page. If you are not yet a customer, you can try our 30-day free trial to check out the newest features.

You can also contact us through our support forumsfeedback portal, or support portal. We are always happy to assist you!

Related blogs


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed