I guess, you are using a style to apply this Template
to ToggleButton
. If not, create a default style for ToggleButton
and Set Template
property to your ControlTemplate
<Style TargetType="ToggleButton">
<Setter Property="Template" Value="{StaticResource ClipBoardButton1}" />
</Style>
And, coming to your problem around using DataTriggers, I wouldn't add DataTriggers
to ControlTemplate
, because, think about this scenario, what happens when you want to use this same template at a different place where the property name is different (not myProperty
)?
To achieve what you are trying, you can update your Trigger
in the ControlTemplate
to the following:
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content" Value="IS TRUE" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ButtonDownTimeLine}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource ButtonUpTimeLine}"/>
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Content" Value="IS FALSE"></Setter>
</Trigger>
and Bind IsChecked
property of ToggleButton
to your myProperty
<ToggleButton Height="34" HorizontalAlignment="Left"
x:Name="toggleBroadcast"
Click="Button_Click"
VerticalAlignment="Top"
Width="133" Margin="180,0,0,0"
IsChecked="{Binding myProperty}"/>
UPDATE
Replace your trigger in ControlTemplate
with:
<DataTrigger Binding="{Binding myProperty}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ButtonDownTimeLine}"/>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource ButtonUpTimeLine}"/>
</DataTrigger.ExitActions>
</DataTrigger>