It's not that the Interaction.Triggers
aren't being called - they ARE being called, it's the ChangePropertyAction
which is problematic.
For example, this will work fine:
<Style x:Key="MyThingy" TargetType="ContentControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<Rectangle Fill="Red">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<ei:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"
PropertyName="Visibility"
Value="Collapsed" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Rectangle>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Notice the only changes I did were 1. Make the rectangle red (so you can better see when it disappears) and 2. Make the trigger hide the rectangle as soon as you click the button.
So why is my code working? Because instead of using TargetName
, I'm using TargetObject
and binding to the templated parent. You cannot target elements in the template via name, it's a different namescope, also as far as I recall TargetName doesn't work in Styles at all, only in ControlTemplate.Triggers