-1

When I hover my mouse over the button, the background changes to default lightblue background, Why do my triggers not trigger?

<Style TargetType="Button" x:Key="btnBase">
    <Setter Property="OverridesDefaultStyle" Value="True"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">
                <Button Name="Button"
                        FontFamily="/Resources/Fonts/Source Sans Pro/#Source Sans Pro"
                        FontWeight="Bold"
                        FontSize="15"
                        BorderThickness="2"
                        Padding="14,3,14,3"
                        Foreground="{DynamicResource btnBaseForegroundColor}"
                        BorderBrush="{DynamicResource btnBaseBorderBrushColor}"
                        Background="{DynamicResource btnBaseBackgroundColor}">
                    <ContentPresenter/>
                </Button>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="Black"></Setter>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
TheLethalCoder
  • 6,668
  • 6
  • 34
  • 69
A.Game
  • 49
  • 6
  • You must go deeper with the button template and add additional layers, you did not see inception? But seriously, try removing the x:Key definition or adding the Style="{DynamicResource btnBase}" to the xaml you make the buttons. Also you should use TemplateBinding to the background in the style and set the default with a Setter. – Janne Matikainen Dec 08 '16 at 10:33
  • See if this answer can help : http://stackoverflow.com/questions/17259280/how-do-you-change-background-for-a-button-mouseover-in-wpf – Naresh Ravlani Dec 08 '16 at 10:37
  • Ive looked at it, but doesnt help. My buttons change size when i try your link example – A.Game Dec 08 '16 at 11:05

1 Answers1

0

The Background property is not used to color the face of the (standard) button.

So the trigger works but it does not have the effect you are expecting.

Emond
  • 50,210
  • 11
  • 84
  • 115