Click here to Skip to main content
14,930,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I wan to change the background color of a button in a groupBox when it's selected.
I don't find the trigger for this.

<Style x:Key="MyButton" TargetType="Button">
 <Setter Property="OverridesDefaultStyle" Value="True" />
 <Setter Property="Cursor" Value="Hand" />
 <Setter Property="Template">
  <Setter.Value>
    <ControlTemplate TargetType="Button">
     <Border Name="border" CornerRadius="5" Height="48" Width="48 Background="#424242" BorderThickness="0">
     <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
       </Border>
         <ControlTemplate.Triggers>
           <Trigger Property="IsMouseOver" Value="True">
             <Setter Property="Opacity" Value="0.8" />
                </Trigger>
                   <Trigger Property="ToggleButton.IsPressed" Value="True">
                      <Setter TargetName="border" Property="Background" Value="Orange" />
                </Trigger>
                </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


What I have tried:

Toggle.Pressed for example is changing the background for a second

<Trigger Property="ToggleButton.IsPressed" Value="True">
 <Setter TargetName="border" Property="Background" Value="Orange" />
</Trigger>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900