我有一个我制作了自定义样式的工具栏。
<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}"/>
光标有效,但是背景属性没有,为什么?
我测试了您的代码,这是修复
<ToolBarPanel Style="{StaticResource toolbar_opciones}"/>
仔细观察它,您缺少关闭Style
属性的双引号。当我将其添加到XAML
中时,已应用Background
。
欢呼。