0

Im trying to change some properties of a button in WPF like foreground or background when I hover the mouse but the background still uses the default background instead of changing, and if i use the property 'OverridesDefaultStyle', the text or border of the button no longer appears.

Here is the style I define

<Style x:Key="Default_Button" TargetType="Button">
        <Setter Property="Background" Value="#FF262438" />
        <Setter Property="BorderBrush" Value="#FFD4D4D4" />
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="Foreground" Value="#FFD4D4D4" />
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Black" />
                <Setter Property="Foreground" Value="White" />
                <Setter Property="BorderBrush" Value="White" />
            </Trigger>
        </Style.Triggers>
    </Style>

Here is button

<Button
                x:Name="Button"
                Width="200"
                Height="70"
                Margin="10,10,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Content="-B-"
                FontSize="20"
                Style="{StaticResource Default_Button}" />

0 Answers0