<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- 定义按钮样式-->
<Style TargetType="Button">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="buttonbackground">
<Grid.Background>
<ImageBrush ImageSource="/WpfApplication1;component/image/button.png"></ImageBrush>
</Grid.Background>
<ContentPresenter Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="buttonbackground" Property= "Background">
<Setter.Value>
<ImageBrush ImageSource="/WpfApplication1;component/image/button2.png"></ImageBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="buttonbackground" Property= "Background">
<Setter.Value>
<ImageBrush ImageSource="/WpfApplication1;component/image/button3.png"></ImageBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="buttonbackground" Property= "Background">
<Setter.Value>
<ImageBrush ImageSource="/WpfApplication1;component/image/button4.png"></ImageBrush>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
联系客服