In my WPF application, I have the standard Generic.xaml file, which contains a style for my custom class, Frost.
I need to find a way to hook up the Completed event of one of the animations to my custom Frost class, I cannot do it at runtime because it complains at me that i need to set IsFrozen to false which I do not want to do (because of performance).
How can I hook up events to the TargetType of the control template?
<Style TargetType="{x:Type Controls:Frost}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:Frost}">
<ControlTemplate.Resources>
<Storyboard x:Key="OnEndFrost">
<DoubleAnimation Name="fadeOutFrostAnimation"
BeginTime="00:00:00"
Duration="00:00:02"
Storyboard.TargetName="frostElement"
Storyboard.TargetProperty="(UIElement.Opacity)"
To="0">
</DoubleAnimation>
</Storyboard>
</ControlTemplate.Resources>
<Grid>
<MediaElement x:Name="frostElement"
LoadedBehavior="Manual"
Width="1172"
Height="286.917"
Source="{TemplateBinding SourceUri}"
ScrubbingEnabled="True">
<MediaElement.Effect>
<eff:ChromaKeyAlphaEffect InputColor="#FF0E425E" Tolerance="0.1" />
</MediaElement.Effect>
</MediaElement>
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="Controls:Frost.EndFrost">
<BeginStoryboard x:Name="OnEndFrost_BeginStoryboard" Storyboard="{StaticResource OnEndFrost}"/>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>