1、模板的,只对某一个控件进行修改
<Button> <Button.Template> <ControlTemplate TargetType="Button"> <Image x:Name="image" Source=".\button_up.png" /> <ControlTemplate.Triggers> <Trigger Property="IsPressed" Value="True"> <Setter TargetName="image" Property="Source" Value=".\button_down.png"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> 2、style的,对所有的相同的控件,属性进行修改
<Style TargetType="{x:Type Button}" x:Key="ButtonStyle">
<Style.Triggers>
<!--鼠标滑过按钮时按钮的发光效果-->
<Trigger Property="Button.IsMouseOver" Value="True">
<Trigger.Setters>
<Setter Property="Image.Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="40" ShadowDepth="1" Color="White" Opacity="0.7"/>
</Setter.Value>
</Setter>
</Trigger.Setters>
</Trigger>
<!--按钮按下时按下弹起效果-->
<Trigger Property="Button.IsPressed" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.95" ScaleY="0.95"/>
</Setter.Value>
</Setter>
<Setter Property="RenderTransformOrigin" Value=".5,.5"/>
</Trigger>
</Style.Triggers>
</Style>