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

.NET MAUI TemplatedButton Visual States

The TemplatedButton provides the following CommonStates visual states:

Visual States Description
Normal Applies when the button is in normal state.
Pressed Applies when the button is pressed.
PointerOver (Desktop-only) Applies when the mouse pointer hovers over the control.
Disabled Applies when the button is disabled.

Using the Visual States

The following example demonstrates how to use the TemplatedButton visual states.

1. Define the TemplatedButton in XAML:

<VerticalStackLayout Spacing="20" HorizontalOptions="Center">
    <HorizontalStackLayout Spacing="5">
        <telerik:RadCheckBox x:Name="checkBox"
                             CheckedColor="#00897B" />
        <Label Text="IsEnabled?"
               telerik:RadCheckBox.ToggleOnTap="{x:Reference checkBox}" />
    <telerik:RadTemplatedButton IsEnabled="{Binding IsChecked, Source={x:Reference checkBox}}"
                                Style="{StaticResource CustomButtonStyle}" />

2. Define the visual states in the page's resources:

<Style x:Key="CustomButtonStyle" TargetType="telerik:RadTemplatedButton">
    <Setter Property="TextColor" Value="#00897B" />
    <Setter Property="VisualStateManager.VisualStateGroups">
                <VisualStateGroup Name="CommonStates">
                    <VisualState Name="Normal" />
                    <VisualState Name="PointerOver">
                            <Setter Property="Background" Value="#E8F5F4" />
                    <VisualState Name="Pressed">
                            <Setter Property="TextColor" Value="#9900897B" />
                            <Setter Property="Background" Value="#E8F5F4" />
                    <VisualState Name="Disabled">
                            <Setter Property="TextColor" Value="#6100897B" />

3. Add the telerik namespace:


This is the result on WinUI:

.NET MAUI TemplatedButton Visual States

For a runnable example demonstrating the TemplatedButton visual states, see the SDKBrowser Demo Application and go to the TemplatedButton > Features category.

See Also

In this article