wpf样式触发器鼠标划过按钮问题
<Window x:Class="WpfTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="Style1" TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="16"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="BlanchedAlmond"></Setter>
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Button Style="{StaticResource Style1}" Margin="23,32,95,139" Content="按钮1"/>
</Grid>
</Window>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="Button1">
<Setter.Value>
<SolidColorBrushColor="BlanchedAlmond" />
</Setter.Value>
</Setter>
</Trigger>
[解决办法]
你的代码确实没问题,我测试时一直显示那颜色,不是只显示一下的