我的按钮触发不起作用

时间:2016-12-08 10:25:20

标签: c# wpf

当我将鼠标悬停在按钮上时,背景会变为默认的浅蓝色背景,为什么我的触发器不会触发?

<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>

1 个答案:

答案 0 :(得分:0)

Background属性不用于为(标准)按钮的面部着色。

因此触发器有效,但它没有你期望的效果。

相关问题