Hello,
I have prepared a control template for the label and stored in App.xaml because these control template is used by many labels in the xaml. Inside it i have a placed a storyboard in order to blink the label constantly.
Here is the code for the same in App.xaml
<ControlTemplate x:Key="LabelControlTemplate1" TargetType="{x:Type Label}">
<ControlTemplate.Resources>
<Storyboard x:Name="BlinkLabel" x:Key="BlinkLabel" RepeatBehavior="Forever" >
<ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="LabelBorder" Storyboard.TargetProperty="(Border.BorderThickness)">
<SplineThicknessKeyFrame KeyTime="00:00:00" Value="0,0,0,0"/>
<SplineThicknessKeyFrame KeyTime="00:00:01" Value="3,3,3,3"/>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Grid Background="{x:Null}" Cursor="Hand" Style="{TemplateBinding Style}">
<Border x:Name="LabelBorder" BorderThickness="0,0,0,0" CornerRadius="2,2,2,2" BorderBrush="#FFFB0505" Cursor="Hand" Background="#00FFFFFF" />
<Label Cursor="Hand" />
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard x:Name="StartBlinkingStoryboard" Storyboard="{StaticResource BlinkLabel}"/>
</EventTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="LabelBorder" Property="BorderThickness" Value="3,3,3,3"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
now there is a button in window1.xaml which will be global to all the xaml(I have application which changes the xaml in the main window called Window1.xaml)
So when i toggle this button i want to start/stop the animation. this has to be done runtime.
so is there anyway i can trigger the storyboard / animation with the button that is in the another XAML......
Any help will be appreciated.
Thanks, Dhaval Shah [email protected]