鼠标移动到按钮上改变背景颜色
zz962 2014-01-24 05:44:10 我希望实现鼠标移动到按钮上之后,按钮背景色发生改变。
我的XAML如下
<Window x:Class="ButtonDemo.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<Style x:Key="BigFontButton">
<Style.Triggers>
<Trigger Property="Control.IsMouseOver" Value="True">
<Setter Property="Control.Background" Value="DarkRed" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Button Width="214" Style="{StaticResource BigFontButton}" Content="WPF Trigger Sample"></Button>
</Grid>
</Window>
实际运行的效果是鼠标移上之后颜色变了一下,但又恢复成原来的颜色。