C# 我的按钮触发器坏了
当我将鼠标悬停在按钮上时,背景会变为默认的浅蓝色背景,为什么我的触发器不会触发C# 我的按钮触发器坏了,c#,wpf,C#,Wpf,当我将鼠标悬停在按钮上时,背景会变为默认的浅蓝色背景,为什么我的触发器不会触发 <Style TargetType="Button" x:Key="btnBase"> <Setter Property="OverridesDefaultStyle" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTem
<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>
背景属性不用于给(标准)按钮的表面上色
因此,触发器可以工作,但没有达到您预期的效果。您必须更深入地使用按钮模板并添加其他层,您没有看到inception吗?但认真地说,请尝试删除x:Key定义或将Style=“{DynamicResource btnBase}”添加到您创建按钮的xaml中。另外,你应该在样式中使用TemplateBinding到背景,并使用Setter设置默认值。看看这个答案是否有用:我看过了,但没有帮助。当我尝试你的链接时,我的按钮会改变大小示例有任何示例吗?@A.Game-请参阅: