AutoSizing in .NET MAUI ComboBox (SfComboBox)

4 May 20251 minute to read

AutoSizing can be enabled in the SfComboBox control so that the control will extend its layout based on the input content.

The EnableAutoSize property is used to enable the auto sizing in the SfComboBox control. To enable the API, set the SelectionMode as Multiple and TokensWrapMode as Wrap. The default value of EnableAutoSize is false.

<editors:SfComboBox x:Name="comboBox"
             ItemsSource="{Binding SocialMedias}"
             SelectionMode="Multiple"
             MaxDropDownHeight="250"
             DisplayMemberPath="Name"
             TextMemberPath="Name"
             Placeholder="Enter Media"
             TokensWrapMode="Wrap"
             EnableAutoSize="True" />
SfComboBox comboBox = new SfComboBox() 
{
        ItemsSource = socialMediaViewModel.SocialMedias,
        SelectionMode=ComboBoxSelectionMode.Multiple,
        MaxDropDownHeight = 250,
        DisplayMemberPath = "Name",
        TextMemberPath = "Name",
        Placeholder="Enter Media",
        TokensWrapMode=ComboBoxTokensWrapMode.Wrap,
        EnableAutoSize = true

};

.NET MAUI ComboBox AutoSize.