I would like to have have a Style
definition for a TextBlock
include Triggers
.
I know I can put the triggers on individual elements, as such:
<TextBlock x:Name="MyTextBlock" Canvas.Left="0" Text="Some Text"
Style="{StaticResource HeaderText}">
<TextBlock.Triggers>
<EventTriggerRoutedEvent="TextBlock.MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation From="0" To="50"
Duration="0:0:0.4"
Storyboard.TargetName="MyTextBlock"
Storyboard.TargetProperty="(Canvas.Left)"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
But I would like to have the Trigger
live in the "HeaderText" Style.
Anything to be done? I want to be able to switch out the styles on the TextBlock
at runtime, and ideally all the animation triggers would go along with the style.
Or is there another way to solve this problem? I want to associate the visual style and storyboards and apply them together to elements at runtime.
(Using Silverlight 4)