WPF DataTemplate - Overlay
- by David Ward
I have a class that I need to provide the datatemplate for. Currently I have two datatemplates, one for when Enabled == true and one for when Enabled == false. The datatemplate for the class is actually the one below which changes the template used based on a trigger:
<DataTemplate x:Key="ActionNodeTemplateSelector">
<ContentPresenter Content="{Binding}" Name="cp" />
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Enabled}" Value="True">
<Setter TargetName="cp" Property="ContentTemplate" Value="{StaticResource ActionNodeTemplate}" />
</DataTrigger>
<DataTrigger Binding="{Binding Enabled}" Value="False">
<Setter TargetName="cp" Property="ContentTemplate" Value="{StaticResource ActionNodeDisabledTemplate}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
This all works well.
However, now I want to also display an image overlay if the "Completed" property is true and a different image if it is incomplete.
I could easily carry on using my approach to trigger on the Completed property as well but this would double the number of templates and feels wrong.
Is there a way that I could have a trigger on my DataTemplate that will allow me to overlay the correct image over the existing template which is based on the Enabled property?