I have a ControlTemplate that i defined for showing a View model in my required format. However, I am not able to set the Image\'s source property from the DataTrigger of the Co
fine , wierd contorl design ...
<DataTrigger Binding="{Binding Path=DataContext.IsConnected,
RelativeSource={RelativeSource AncestorType=ItemsControl}}" Value="True">
<Setter Property="Source"
TargetName="imgConnectedStatus"
Value="/Resources/GreenDot.png"/>
</DataTrigger>
since you are using a DataTrigger from an item's precpective , the DataTemplates DataContext is an object from your ItemsSource , RelativeSource to the containing control , Path to it's DataContext.Property
By looking at the following link http://social.msdn.microsoft.com/Forums/vstudio/en-US/a3bf91a8-e618-41c6-a1ad-be9e19581fd6/datatrigger-inside-controltemplate-issue
It became clear that i should not use TemplatedParent. Setting the {RelativeSource Self} in the binding solved the problem.
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding AdditionalContent.IsComponentShutdown, RelativeSource={RelativeSource Self}}"
Value="False">
<Setter TargetName="imgStatus"
Property="Source"
Value="/Resources/GreenDot.png"/>
</DataTrigger>
</ControlTemplate.Triggers>