6
如何在WPF中更改Button MouseOver的背景?
我的页面上带有此XAML的按钮: <Button Content="Button" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="50" Height="50" HorizontalContentAlignment="Left" BorderBrush="{x:Null}" Foreground="{x:Null}" Margin="50,0,0,0"> <Button.Style> <Style TargetType="Button"> <Setter Property="Background" Value="Green"/> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="Red"/> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button> 但是,当我将鼠标放在按钮上时,按钮的背景会更改为默认窗口的灰色背景。有什么问题? 这是鼠标悬停之前和之后的按钮图片: 之前: 之后: