P
P
postya2019-12-01 17:55:39
WPF
postya, 2019-12-01 17:55:39

How to change background color of toggle button in WPF?

Using WPF in Visual Studio
Created a toggle button. I want the background of the button to change when the mouse is hovered over.
The background property for hovering the mouse over the button does not work, but all other properties work, and when I hover over the button, the background becomes light blue, I didn’t specify this color anywhere, apparently it’s written somewhere according to the standard
How can I change the background when hovering the mouse over toggle button?

<ToggleButton Name="toggle" Grid.Column="0" Grid.Row="0" BorderThickness="0" MinHeight="30" Margin="20">
            <ToggleButton.Style>
                <Style TargetType="{x:Type ToggleButton}">
                    
                    <Style.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter Property="Content" Value="ARMED"/>
                            <Setter Property="Foreground" Value="Red"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Cursor" Value="Hand"/>
                            <Setter Property="Content" Value="Mous is over"/>
                            <Setter Property= "Background" Value="Red"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ToggleButton.Style>
        </ToggleButton>
>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question