Introducing the .NET MAUI Autocomplete Control
Tags: dotnet, csharp, maui, mobile
Published: 2022-10-10 12:40:29

---
title: Introducing the .NET MAUI Autocomplete Control
published: true
date: 2022-10-06 10:30:03 UTC
tags: dotnet, csharp, maui, mobile
canonical_url: https://www.syncfusion.com/blogs/post/dotnet-maui-autocomplete-control.aspx
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkutcicktabl8bt5ieov.png
---

An Autocomplete control was one of the most-requested controls by our mobile app developers. We at [Syncfusion](https://www.syncfusion.com/ "Syncfusion UI componentS") understand the requirement for this essential control and have now delivered the [.NET MAUI Autocomplete](https://www.syncfusion.com/maui-controls/maui-autocomplete ".NET MAUI Autocomplete control") control in our [2022 Volume 3](https://www.syncfusion.com/forums/177858/essential-studio-2022-volume-3-main-release-v20-3-0-47-is-available-for-download "Essential Studio 2022 Volume 3") release.

In this article, we will see the key features of the new .NET MAUI Autocomplete control and the steps to get started with it.

## .NET MAUI Autocomplete

The .NET MAUI Autocomplete control is highly optimized to load and populate suggestions from a massive volume of data depending on the users’ input characters. It allows users to select one or more items from the suggestion list. It displays the selected items in the input view as text and removes the text when the close buttons are tapped.

## Getting started with .NET MAUI Autocomplete

This section explains the steps to getting started with .NET MAUI Autocomplete control, populating it with data, and filtering the suggestions.

**Step 1** : Syncfusion .NET MAUI components are available on the [NuGet Gallery](https://www.nuget.org/ "NuGet Gallery"). To add the **SfAutoComplete** to your project, open the  **NuGet package manager** in Visual Studio. Search for **Syncfusion.Maui.Inputs** , and then install the NuGet package.

**Step 2** : Then, register the handler for Syncfusion core in the  **MauiProgram.cs** file.

```csharp
using Syncfusion.Maui.Core.Hosting;
using Syncfusion.Maui.ListView.Hosting;

public static class MauiProgram
{
 public static MauiApp CreateMauiApp()
 {
  var builder = MauiApp.CreateBuilder();
  builder
  .UseMauiApp<App>()
  .ConfigureSyncfusionCore()
  .ConfigureSyncfusionListView()
  .ConfigureFonts(fonts =>
  {
    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
    fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
  });
  return builder.Build();
 }
}
```

**Step 3** : Import the SfAutoComplete namespace in the XAML page.

```xml
xmlns:inputs="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs"
```

**Step 4** : Then, initialize an empty autocomplete control like in the following code.

```xml
<inputs:SfAutocomplete x:Name="autocomplete" WidthRequest="200"/>
```

**Step 5** : Now, create the required data to populate the suggestions list. This includes creation of the example **Person** class, and **PersonsViewModel** with the list of **Person** objects.

```csharp
public class Person
{
 public string Name { get; set; }
 public string SecondName { get; set; }
}
public class PersonsViewModel : INotifyPropertyChanged
{
 readonly IList<Person> source;
 Person selectedPerson;
 private string selectedItem;
 public ObservableCollection<Person> Persons { get; private set; }
 public List<string> Items { get; private set; }
 public Person SelectedPerson
 {
  get
  {
    return selectedPerson;
  }
  set
  {
    if (selectedPerson != value)
    {
      selectedPerson = value;
      OnPropertyChanged("SelectedPerson");
    }
  }
}
public string SelectedItem
{
 get
 {
  return selectedItem;
 }
 set
 {
  if (selectedItem != value)
  {
   selectedItem = value;
   OnPropertyChanged("SelectedItem");
  }
 }
}
public PersonsViewModel()
{
  source = new List<Person>();
  CreatePersonCollection();
  
  SelectedPerson = Persons.Skip(3).FirstOrDefault();
}
void CreatePersonCollection()
{
  for (int i = 0; i < 1; i++)
  {
   source.Add(new Person { Name = "Adam", SecondName = "A" });
   source.Add(new Person { Name = "Bob", SecondName = "A" });
   source.Add(new Person { Name = "John", SecondName = "D" });
   source.Add(new Person { Name = "Alan", SecondName = "E" });
   source.Add(new Person { Name = "Alex", SecondName = "F" });
   source.Add(new Person { Name = "Jacob", SecondName = "R" });
   source.Add(new Person { Name = "Peter", SecondName = "J" });
   source.Add(new Person { Name = "Clark", SecondName = "L" });
   source.Add(new Person { Name = "Ben", SecondName = "A" });
   source.Add(new Person { Name = "Dave", SecondName = "S" });
  }
  Persons = new ObservableCollection<Person>(source);
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
  PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
```

**Step 6:**  Finally, set the binding context to the **PersonsViewModel,** bind the **ItemsSource** with the  **Persons** list and bind the  **DisplayMemberPath** property with the **Name** property.

```xml
<ContentPage.BindingContext>
  <local:PersonsViewModel/>
</ContentPage.BindingContext>
<inputs:SfAutocomplete WidthRequest="200"
                       ItemsSource="{Binding Persons}"
                       DisplayMemberPath="Name"/>
```

That’s it. Our .NET MAUI Autocomplete control is now ready.
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2022/09/NET-MAUI-Autocomplete-1.png" alt=".NET MAUI Autocomplete" style="width:100%">

  <figcaption>.NET MAUI Autocomplete Control</figcaption>

</figure>



## Key features in .NET MAUI Autocomplete

### Text Search Mode

The **TextSearchMode** property of the .NET MAUI Autocomplete control regulates the control’s behavior when it receives user input. The available text filter modes are:

- StartsWith
- Contains

### Placeholder Text

The **PlaceholderText** property prompts the user with information that can be searched using the Autocomplete control. This text will be displayed only if no items are selected and the edit text is empty. The default value of the **PlaceholderText** property is **string.Empty** (no string will be displayed).

Refer to the following code example.

```xml
<inputs:SfAutocomplete WidthRequest="200" 
                       HeightRequest="40"
                       ItemsSource="{Binding Persons}"
                       TextSearchMode="StartsWith"
                       PlaceholderText="Search"
                       DisplayMemberPath="Name"/>
```
<figure>

  <img src="https://www.syncfusion.com/blogs/wp-content/uploads/2022/09/NET-MAUI-Autocomplete-with-Placeholder-text.png" alt=".NET MAUI Autocomplete with Placeholder text" style="width:100%">

  <figcaption>.NET MAUI Autocomplete with Placeholder text</figcaption>

</figure>



### Color customization

Also, you can customize the border color, placeholder text, text color, and clear button icon color as in the following code example.

```xml
<inputs:SfAutocomplete WidthRequest="200" 
                       HeightRequest="30"
                       ItemsSource="{Binding Persons}"
                       TextSearchMode="StartsWith"
                       PlaceholderText="Search"
                       ClearButtonIconColor="DeepPink"
                       PlaceholderTextColor="HotPink"
                       TextColor="DeepPink"
                       DisplayMemberPath="Name"/>
```

## Upcoming features

This is the initial version of our Syncfusion .NET MAUI Autocomplete control. You can expect the following features in our upcoming releases:

- MultiSelection with chip UI
- Diacritic sensitivity
- Item templates
- Text match highlights
- Dropdown header and footer
- Custom filtering

##  Conclusion

Thanks for reading! In this blog, we have seen the features of the new [.NET MAUI Autocomplete](https://www.syncfusion.com/maui-controls/maui-autocomplete ".NET MAUI Autocomplete") control available in our [2022 Volume 3](https://www.syncfusion.com/forums/177858/essential-studio-2022-volume-3-main-release-v20-3-0-47-is-available-for-download "Essential Studio 2022 Volume 3") release. Check out our [Release Notes](https://help.syncfusion.com/common/essential-studio/release-notes/v20.3.0.47 "Syncfusion Release Notes page") and [What’s New](https://www.syncfusion.com/products/whatsnew "Syncfusion What's New page") pages to see the other updates. You can download the [Essential studio for .NET MAUI](https://www.syncfusion.com/downloads/maui "Essential studio for .NET MAUI") to evaluate this control.

You can contact us through our [support forum](https://www.syncfusion.com/forums "Syncfusion support forum"), [support portal](https://support.syncfusion.com/ "Syncfusion support portal"), or [feedback portal](https://www.syncfusion.com/feedback/ "Syncfusion feedback Portal"). We are always happy to assist you!

## Related blogs

- [Syncfusion Essential Studio 2022 Volume 3 Is Here!](https://www.syncfusion.com/blogs/post/syncfusion-essential-studio-2022-volume-3-is-here.aspx "Blog: Syncfusion Essential Studio 2022 Volume 3 Is Here!")
- [What’s New in .NET MAUI: 2022 Volume 3](https://www.syncfusion.com/blogs/post/whats-new-in-net-maui-2022-volume-3.aspx "Blog: What’s New in .NET MAUI: 2022 Volume 3")
- [Configure Syncfusion .NET MAUI Controls Using Visual State Manager (VSM)](https://www.syncfusion.com/blogs/post/configure-syncfusion-net-maui-controls-using-visual-state-manager.aspx "Blog: Configure Syncfusion .NET MAUI Controls Using Visual State Manager (VSM)")
- [Create Group Chat Profile View in .NET MAUI App](https://www.syncfusion.com/blogs/post/create-group-chat-profile-view-in-net-maui-app.aspx "Blog: Create Group Chat Profile View in .NET MAUI App")