1. 首先建2个样式
<Style x:Key="SnapStartCommandButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<StackPanel Orientation="Vertical" Background="Transparent" Margin="0,0,0,0" >
<Image x:Name="ProgressImage" Source="/Custom;component/Images/snapStart1.png" Stretch="Fill"/>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Source" Value="/Custom;component/Images/snapStart2.png" TargetName="ProgressImage"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Source" Value="/Custom;component/Images/snapStart1.png" TargetName="ProgressImage"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Source" Value="/Custom;component/Images/snapStart2.png" TargetName="ProgressImage"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StackStartCommandButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<StackPanel Orientation="Vertical" Background="Transparent" Margin="0,0,0,0" >
<Image x:Name="ProgressImage" Source="/;component/Images/stackStart1.png" Stretch="Fill"/>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Source" Value="/;component/Images/stackStart2.png" TargetName="ProgressImage"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Source" Value="/;component/Images/stackStart1.png" TargetName="ProgressImage"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Source" Value="/;component/Images/stackStart2.png" TargetName="ProgressImage"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2. 代码里替换
button.SetResourceReference(Button.StyleProperty,
"SnapStartCommandButtonStyle");
button.SetResourceReference(Button.StyleProperty,
"StackStartCommandButtonStyle");