Editing in .NET MAUI ComboBox (SfComboBox)

21 Jun 20243 minutes to read

The ComboBox control supports both editable and non-editable text boxes for selecting an item from a data source. To enable editing functionality, set IsEditable property as true. The default value is false.

Editable ComboBox

In the editable mode, the ComboBox allows users to edit in the text box and it automatically appends the remaining letters to the entered text when it is valid.

<editors:SfComboBox x:Name="comboBox"
                    WidthRequest="250"
                    IsEditable="true"
                    ItemsSource="{Binding SocialMedias}"
                    DisplayMemberPath="Name"
                    TextMemberPath="Name">
</editors:SfComboBox>
comboBox.IsEditable = true;

The following image illustrates the result of the above code:

.NET MAUI ComboBox choose item using editing

Non-editable ComboBox

Non-editable mode prevents users from editing and instead allows them to select from the drop-down list.

<editors:SfComboBox x:Name="comboBox"
                    WidthRequest="250"
                    IsEditable="false"
                    ItemsSource="{Binding SocialMedias}"
                    DisplayMemberPath="Name"
                    TextMemberPath="Name">
</editors:SfComboBox>
comboBox.IsEditable = false;

The following gif image illustrates the result of the above code:

.NET MAUI ComboBox choose item using non editing mode

Hide clear button in the editor

By default, the clear button X will be displayed in the editor of the ComboBox control, which can be used to clear the entered input. Hide the clear button in ComboBox control using the IsClearButtonVisible property. The default value of the IsClearButtonVisible property value is true.

<editors:SfComboBox x:Name="comboBox"
                    WidthRequest="250"
                    IsEditable="true"
                    IsClearButtonVisible="false"
                    ItemsSource="{Binding SocialMedias}"
                    DisplayMemberPath="Name"
                    TextMemberPath="Name">
</editors:SfComboBox>
comboBox.IsClearButtonVisible = false;

NOTE

The IsClearButtonVisible property has no effect in non-editable mode.

The following gif image illustrates the result of the above code:

.NET MAUI ComboBox clear button visibility