C# 如何使用触发器或任何其他事件更改wpf中onmoveover、onmouseleave的按钮颜色
我开发了一个带有一些按钮的WPF应用程序。现在我想通过使用触发器或任何其他事件来更改mouseover、onmouseleave和onmouseenter上这些按钮的颜色。 有什么建议吗C# 如何使用触发器或任何其他事件更改wpf中onmoveover、onmouseleave的按钮颜色,c#,wpf,button,triggers,C#,Wpf,Button,Triggers,我开发了一个带有一些按钮的WPF应用程序。现在我想通过使用触发器或任何其他事件来更改mouseover、onmouseleave和onmouseenter上这些按钮的颜色。 有什么建议吗 提前感谢。在所需的事件中,您可以像这样设置背景颜色 // Change the background color of button1 to Blue button1.Background = Brushes.Blue; 您还可以在触发器中设置: <!-- Button will change from
提前感谢。在所需的事件中,您可以像这样设置背景颜色
// Change the background color of button1 to Blue
button1.Background = Brushes.Blue;
您还可以在触发器中设置:
<!-- Button will change from Blue to Yellow on MouseOver -->
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="Blue" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Yellow" />
</Trigger>
</Style.Triggers>
</Style>
有关更多详细信息,请查看文章的属性触发器部分。在这个问题中可以找到此解决方案的问题:同样的问题发生在我身上——它似乎不会设置背景。