当我将鼠标悬停在按钮上时,背景会更改为默认的浅蓝色背景,为什么我的触发器不会触发?我的按钮触发不会工作
<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>
您必须更深入地使用按钮模板并添加额外的图层,您没有看到开始?但严重的是,尝试删除x:Key定义或将Style =“{DynamicResource btnBase}”添加到您制作按钮的xaml中。你也应该在样式中使用TemplateBinding作为背景,并用Setter设置默认值。 –
看看这个答案是否可以帮助:http://stackoverflow.com/questions/17259280/how-do-you-change-background-for-a-button-mouseover-in-wpf –
我看了看,但没有帮助。当我尝试你的链接示例时,我的按钮更改大小 –