Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
样式中的悬停效果不';t工作(工具栏面板)-WPF c#_C#_Wpf_Xaml_User Interface - Fatal编程技术网

样式中的悬停效果不';t工作(工具栏面板)-WPF c#

样式中的悬停效果不';t工作(工具栏面板)-WPF c#,c#,wpf,xaml,user-interface,C#,Wpf,Xaml,User Interface,我有一个自定义样式的工具栏面板 <Window.Resources> <Style x:Key="toolbar_opciones" TargetType="{x:Type ToolBarPanel}"> <Setter Property="Background" Value="DeepSkyBlue"/> <!-- does not work --> <Setter Property="Cursor"

我有一个自定义样式的工具栏面板

<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


干杯

我测试了你的代码,下面是修复方法

<ToolBarPanel Style="{StaticResource toolbar_opciones}"/>

仔细看,您缺少关闭
Style
属性的双引号。当我将其添加到
XAML
中时,已经应用了
Background


干杯

当鼠标悬停在元素上时,
background
属性是否会更改?还要确保当鼠标悬停在元素上时,并且我没有编写任何C代码时,不会覆盖C代码中的background属性,所以背景属性没有被覆盖。你可以尝试背景属性的另一个值吗。例如,试一试黑色为什么更改颜色可以解决问题?当鼠标悬停在元素上时,
background
属性是否会更改?还要确保当鼠标悬停在元素上时,并且我没有编写任何C代码时,您没有覆盖C代码中的background属性,所以背景属性没有被覆盖。你可以尝试背景属性的另一个值吗。例如,试试黑色为什么改变颜色可以解决这个问题?啊,对不起,我输入这个问题时出错了。可能是因为我使用的是NetFramework4.5?啊,对不起,我输入问题时出错了。可能是因为我使用的是NetFramework4.5?