Introducing the New .NET MAUI ComboBox Control | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (173).NET Core  (29).NET MAUI  (203)Angular  (107)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (211)BoldSign  (13)DocIO  (24)Essential JS 2  (106)Essential Studio  (200)File Formats  (65)Flutter  (132)JavaScript  (219)Microsoft  (118)PDF  (81)Python  (1)React  (98)Streamlit  (1)Succinctly series  (131)Syncfusion  (897)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (50)Windows Forms  (61)WinUI  (68)WPF  (157)Xamarin  (161)XlsIO  (35)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (146)Chart  (127)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (618)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (39)Extensions  (22)File Manager  (6)Gantt  (18)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  (501)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (42)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (381)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (17)Web  (582)What's new  (323)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Introducing the New .NET MAUI ComboBox Control

Introducing the New .NET MAUI ComboBox Control

A ComboBox is a crucial UI element that most mobile app developers use in their projects. We at Syncfusion understand the wide-ranging utility of this control and have now delivered a .NET MAUI ComboBox control in our 2022 Volume 3 release.

In this article, I will summarize the key features of the .NET MAUI ComboBox control and how to get started with it.

.NET MAUI ComboBox

The .NET MAUI ComboBox control is a selection component that allows users to type a value or choose an option from a list of predefined options. It has many features, such as data binding, editing, searching, a clear button, and dropdown button customization.

Getting started with .NET MAUI ComboBox

Let’s see how to get started with the .NET MAUI ComboBox control, populate it with data, and load items.

Step 1: Syncfusion .NET MAUI components are available on the NuGet Gallery. To add the SfComboBox to your project, open the NuGet package manager in Visual Studio. Search for the Syncfusion.Maui.Inputs NuGet package and then install it.

Step 2: Register the handler for the Syncfusion Core package in the MauiProgram.cs file.

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 SfComboBox namespace on the XAML page.

xmlns:inputs=”clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs”

Step 4: Initialize an empty ComboBox control as shown in the following code.

<inputs:SfComboBox x:Name=“combobox” WidthRequest=”200″/>

Step 5: Let’s create the data required to populate the suggestion list. This includes the creation of the example Person class and PersonsViewModel with a list of Person objects.

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: Set the binding context to the PersonsViewModel, bind the ItemsSource with the Persons list, and bind the DisplayMemberPath property with the Name property.

<ContentPage.BindingContext>
  <local:PersonsViewModel/>
</ContentPage.BindingContext>
<inputs:SfComboBox WidthRequest=”200″
                   ItemsSource=”{Binding Persons}”
                   DisplayMemberPath=”Name”/>

That’s it. Our .NET MAUI ComboBox control is now ready.

.NET MAUI ComboBox Control
.NET MAUI ComboBox Control

Customization in .NET MAUI ComboBox

You can perform the following customizations in the .NET MAUI ComboBox control:

Placeholder text

You can prompt the user with any information using the PlaceholderText property. This text will be displayed only if no items are selected or the edit text field is empty. The default value of the PlaceholderText property is string.Empty (no string will be displayed).

Refer to the following code example.

<editors:SfComboBox x:Name="comboBox"
                      WidthRequest="250"
                      ItemsSource="{Binding SocialMedias}"
                      DisplayMemberPath="Name"
                      TextMemberPath="Name"
                      Placeholder="Select a social media" />
Customizing the Placeholder Text in .NET MAUI ComboBox
Customizing the Placeholder Text in .NET MAUI ComboBox

Color customization

You can also customize the color of the ComboBox border, placeholder text, item text, clear button, dropdown icon, and more.

Refer to the following code example where we have customized the border and dropdown icon color.

<editors:SfComboBox x:Name="combobox"
                      WidthRequest=”250”                    
                      ItemsSource="{Binding SocialMedias}"
                      DisplayMemberPath="Name"
                      TextMemberPath="Name"
                      DropDownIconColor="Red"
                      BorderColor="Red" />
Color Customization in .NET MAUI ComboBox
Color Customization in .NET MAUI ComboBox

Upcoming features

This is the initial version of our.NET MAUI ComboBox 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 vivid features of the new .NET MAUI ComboBox control available in our 2022 Volume 3 release. Check out our Release Notes and What’s New pages to see the other updates in this release.

You can also download our free evaluation to see all our .NET MAUI  controls in action.

If you have any questions or comments, you can reach us through our support forum, support portal, or feedback portal. We are always happy to assist you!

Test Flight
App Center Badge
Google Play Store Badge
Microsoft Badge
Github Store Badge

Related blogs

Tags:

Share this post:

Comments (4)

Hi, can the dropdown be customized? It’s missing various Dropdown color properties that existed in Xamarin

Selva Ganapathy Kathiresan
Selva Ganapathy Kathiresan

Hi GEORGE,

Thanks for your interest in our .NET MAUI Combo Box Control. Complete customization features are underway. you can expect those features in any of our upcoming releases
https://help.syncfusion.com/maui/combobox/migration#upcoming-features

Paste the xmlns into the XAML and all I get is an error. Syncfusion is such a poor company especially with docs.

Obviously Syncfusion does not test their docs. Lets use a non usable double quote said the Syncfusion doc manager that will screw them up

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed