Change Background with Trigger event

Good Morning,

The Trigger event in the style not working,

when the button is checked must change background color in Lime.

<Page x:Class="TesmitWpfApp.Views.ManualView"

      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

      xmlns:syncfusion="http://schemas.syncfusion.com/wpf"

      mc:Ignorable="d"

      d:DesignHeight="525" d:DesignWidth="984"

      Title="ManualView">


    <Page.Resources>

        <Style x:Key="ButtonStyle" TargetType="{x:Type syncfusion:ButtonAdv}">

            <Setter Property="SmallIcon" Value="{x:Null}"/>

            <Setter Property="FontSize" Value="30"/>

            <Setter Property="Margin" Value="20"/>

            <Setter Property="IsCheckable" Value="True"/>

            <Setter Property="Foreground" Value="Blue"></Setter>

            <Style.Triggers>

                <Trigger Property="IsChecked" Value="True">

                    <Setter Property="Background" Value="Lime"/>

                </Trigger>

            </Style.Triggers>

        </Style>

    </Page.Resources>


    <Grid>

        <Grid.RowDefinitions>

            <RowDefinition Height="*"/>

            <RowDefinition Height="*"/>

            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="*"/>

            <ColumnDefinition Width="*"/>

            <ColumnDefinition Width="*"/>

        </Grid.ColumnDefinitions>

        <syncfusion:ButtonAdv x:Name="BtnCoverLock" Grid.Row="0" Grid.Column="0"

                              Label="Bloccaggio Coperchio"

                              Style="{StaticResource ButtonStyle}"

                              Click="Button_Click"/>

        <syncfusion:ButtonAdv x:Name="BtnBarFront" Grid.Row="0" Grid.Column="1"

                              Label="Barra Anteriore"

                              Style="{StaticResource ButtonStyle}"

                              Click="Button_Click"/>

        <syncfusion:ButtonAdv x:Name="BtnBarRear" Grid.Row="0" Grid.Column="2"

                              Label="Barra Posteriore"

                              Style="{StaticResource ButtonStyle}"

                              Click="Button_Click"/>

        <syncfusion:ButtonAdv x:Name="BtnEvVacuum" Grid.Row="1" Grid.Column="0"

                              Label="Ev Vuoto"

                              Style="{StaticResource ButtonStyle}"

                              Click="Button_Click"/>

        <syncfusion:ButtonAdv x:Name="BtnEvGas" Grid.Row="1" Grid.Column="1"

                              Label="Ev Gas"

                              Style="{StaticResource ButtonStyle}"

                              Click="Button_Click"/>

        <syncfusion:ButtonAdv x:Name="BtnEvAirReturn" Grid.Row="1" Grid.Column="2"

                              Label="Ev Sfiato"

                              Style="{StaticResource ButtonStyle}"

                              Click="Button_Click"/>

        <syncfusion:ButtonAdv x:Name="BtnPump" Grid.Row="2" Grid.Column="1"

                              Label="Pompa"

                              Style="{StaticResource ButtonStyle}"

                              Click="Button_Click"/>

    </Grid>

</Page>

In the other pages it's ok.


4 Replies

EG Edoardo Gazzola June 28, 2023 08:15 AM UTC

Do you have any recommendations?

Thank You



RS Raghavendra Sudhakar Syncfusion Team June 28, 2023 02:19 PM UTC

Hi Edoardo Gazzola,


To change the background color of the button when it is checked, we recommend overriding the ControlTemplate of the ButtonAdv. We have created an example based on your specifications. Please refer to the attached sample for reference.


Regards,

Raghavendra S


Attachment: ButtonAdv_21bad038.zip


EG Edoardo Gazzola June 28, 2023 04:12 PM UTC

Hi Raghavendra,

I used your style.

Thank you



BA BagavathiPerumal Apranandham Syncfusion Team June 30, 2023 11:54 AM UTC

Hi Edoardo Gazzola,



We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out.




Regards,
Bagavathi Perumal A


Loader.
Up arrow icon