<Window
xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x=
"http://schemas.microsoft.com/winfx/2006/xaml"
>
<Window.Resources>
<!--替换背景img-->
<BitmapImage x:Key=
"MyImageSource"
UriSource=
"替换按钮.png"
/>
<!--Image Style-->
<Style x:Key=
"ImageStyle1"
TargetType=
"{x:Type Image}"
>
<Setter Property=
"FlowDirection"
Value=
"LeftToRight"
/>
<!--原背景img-->
<Setter Property=
"Source"
Value=
"按钮.png"
/>
<Setter Property=
"OpacityMask"
Value=
"{x:Null}"
/>
<Style.Triggers>
<Trigger Property=
"IsMouseOver"
Value=
"True"
>
<Setter Property=
"Source"
Value=
"{StaticResource MyImageSource}"
></Setter>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Image x:Name=
"img"
Style=
"{StaticResource ImageStyle1}"
Width=
"100"
Height=
"200"
></Image>
</Grid>
</Window>