In my application, I have defined an ImageButton
control that specifies an ImageSource
property.
This is styled like this:
<Style TargetType="{x:Type controls:ImageButton}">
<Setter Property="ForceCursor" Value="True" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="ToolTip" Value="{Binding Path=Caption, RelativeSource={RelativeSource Mode=Self}}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:ImageButton}">
<Image Width="16" Height="16" Source="{Binding Path=ImageSource, RelativeSource={RelativeSource Mode=TemplatedParent}}" Name="image" />
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="image" Property="Opacity" Value="0.3" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
But in your case, if you want to use the same image for all Button
objects with a certain Style
set, you could simply just use <Image Source="pack://application:,,,/My.Assembly.Name;component/Icons/revert.png" />
in the Template
if the image you want to use has been included as a resource in the application.