[英]Hover effect in style doesn't work (ToolBarPanel) - WPF c#
I have a toolbarpanel which I've made a custom style. 我有一个工具栏面板,我已经制作了自定义样式。
<Window.Resources>
<Style x:Key="toolbar_opciones" TargetType="{x:Type ToolBarPanel}">
<Setter Property="Background" Value="DeepSkyBlue"/> <!-- does not work -->
<Setter Property="Cursor" Value="Hand"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="CadetBlue"/>
</Trigger> <!-- does not work -->
</Style.Triggers>
</Style>
</Window.Resources>
<ToolBarPanel Style="{StaticResource toolbar_opciones}"/>
The cursor works but the background property no, why? 光标工作,但背景属性没有,为什么?
I tested your code, and here is the fix 我测试了你的代码,这是修复
<ToolBarPanel Style="{StaticResource toolbar_opciones}"/>
look at it closely, you were missing the double quotation which close the Style
attribute. 仔细看看,你错过了关闭Style
属性的双引号。 When I added it to the XAML
, the Background
has been applied. 当我将它添加到XAML
,已应用Background
。
Cheers. 干杯。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.