Вы можете использовать Attached Properties.Это позволит вам указать источник для Images
внутри Template
для каждого Button
экземпляра
<Button Style="{DynamicResource downloadButtonStyle}"
ex:ButtonExtension.DefaultImageSource="DefaultImageSource"
ex:ButtonExtension.MouseOverImageSource="MouseOverImageSource"
ex:ButtonExtension.DisabledImageSource="DisabledImageSource" />
В Template
<ControlTemplate>
<Image x:Name="PART_img" Source="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=(ex:ButtonExtension.DefaultImageSource)}"/
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="PART_img" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=(ex:ButtonExtension.MouseOverImageSource)}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="PART_img" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=(ex:ButtonExtension.DisabledImageSource)}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
ButtonExtension
public class ButtonExtension
{
public static DependencyProperty DefaultImageSourceProperty =
DependencyProperty.RegisterAttached("DefaultImageSource",
typeof(ImageSource),
typeof(ButtonExtension),
new PropertyMetadata(null));
public static ImageSource GetImageSource(DependencyObject target)
{
return (ImageSource)target.GetValue(DefaultImageSourceProperty);
}
public static void SetImageSource(DependencyObject target, ImageSource value)
{
target.SetValue(DefaultImageSourceProperty, value);
}
// Repeat for MouseOverImageSource and DisabledImageSource
}