【发布时间】:2013-06-26 22:04:48
【问题描述】:
我正在尝试在悬停时更改 xaml 中按钮样式的背景颜色 这是我目前的方法,但它不起作用。正在使用默认的悬停颜色
<Style x:Key="AtStyle" TargetType="Button">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="{StaticResource AtBlue}" />
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="White" />
<Setter Property="Padding" Value="12,6" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FontSize" Value="18.667" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Red" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
我看到其他解决方案说您需要覆盖 Control 模板来实现这一点,但这些解决方案还需要您定义边框和内容,这似乎没有必要。在 Xaml 中定义悬停状态的最小方法是什么?
【问题讨论】:
标签: wpf xaml button styles hover