New to Telerik UI for .NET MAUI? Start a free 30-day trial

Setting the Visual States of the ComboBox

Environment

Version Product Author
6.7.0 ComboBox for .NET MAUI Dobrinka Yordanova

Description

How can I set the visual states of the Telerik UI for .NET MAUI ComboBox control?

Solution

To set the visual states of the ComboBox control, configure the VisualStateManager. The VisualStateManager defines a visual state group named CommonStates and supports the Normal, Disabled, Focused, and MouseOver values. As a general recommendation, always configure all available visual states.

<telerik:RadComboBox x:Name="combo" Placeholder="telerik">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroupList>
            <VisualStateGroup x:Name="CommonStates">
                <VisualState x:Name="Normal">
                    <VisualState.Setters>
                        <Setter Property="FontSize" Value="35" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="Focused">
                    <VisualState.Setters>
                        <Setter Property="BackgroundColor" Value="Red" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="Disabled">
                    <VisualState.Setters>
                        <Setter Property="BackgroundColor" Value="Pink" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="Unfocused">
                    <VisualState.Setters>
                        <Setter Property="BackgroundColor"  Value="Yellow" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="MouseOver">
                    <VisualState.Setters>
                        <Setter Property="BackgroundColor"  Value="Green" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateGroupList>
    </VisualStateManager.VisualStateGroups>
</telerik:RadComboBox>

If you want to apply visual states to the elements inside the drop-down, set visual states inside the ComboBox ItemTemplate and SelectedItemTemplate.

In this article