0

I am trying to change the color of a button I made in WPF on mouse hover. This is not working.

<Button x:Name="CloseButton" MouseEnter="CloseButton_MouseEnter" Foreground="White" BorderThickness="0" Click="CloseButton_Clicked" HorizontalAlignment="Right" VerticalAlignment="Top" Height="40" Width="40" Margin="0, 6, 6, 0">
        <Button.Background>
            <SolidColorBrush Color="Black" Opacity="0.5"></SolidColorBrush>
        </Button.Background>
        <Image Source="images/cross-white.png" Margin="10"/>
        <Button.Style>
            <Style>
                <Style.Triggers>
                    <Trigger Property="Button.IsMouseOver" Value="True">
                        <Setter Property="Button.Background" Value="Red" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Button.Style>
    </Button>
  • Yes. It did. I got confused about why I have to set Template but it's also explained in a comment. Thanks –  Aug 07 '21 at 16:10

0 Answers0