<Style x:Key="BackButton" TargetType="Button">
<Setter Property="Foreground" Value="WhiteSmoke"/>
<Setter Property="Background" Value="#33FFFFFF"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Content" Value="×"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="bd" >
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<!--更改Background,即可更改鼠标悬停背景颜色-->
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="bd" Property="Background" Value="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsPressed" Value="True"/>
</MultiTrigger.Conditions>
<Setter TargetName="bd" Property="Background" Value="{x:Null}"/>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
WPF窗口右上角按钮2
最新推荐文章于 2024-07-21 19:17:17 发布