I have a button that has two images attached to its DataContext.
The displayed image is bind to the button IsEnabled property.
Here is the XAML for the button:
<Button Name="SubmitButton" IsEnabled="{Binding IsSubmitEnabled}" Background="Transparent">
<Image Name="SubmitButtonImage" Height="50" Width="291" MinHeight="50" MinWidth="291">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSubmitEnabled}" Value="True">
<Setter Property="Source" Value="/Resources/startup/Submit_enabled.png"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding IsSubmitEnabled}" Value="False">
<Setter Property="Source" Value="/Resources/startup/Submit_disabled.png"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
Now instead of specifying the image in DataTrigger Value I want to use a template that is defined in the file like this:
<ControlTemplate x:Key="SubmitEnabledTemplate" TargetType="{x:Type Button}">
<Border
Height="{TemplateBinding Height}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<Image Source="/Resources/startup/Submit_enabled.png"></Image>
</Border>
</ControlTemplate>
<ControlTemplate x:Key="SubmitDisabledTemplate" TargetType="{x:Type Button}">
<Border
Height="{TemplateBinding Height}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<Image Source="/Resources/startup/Submit_disabled.png"></Image>
</Border>
</ControlTemplate>
Any ideas how to do that?