Currently I have an Image
that I pulse when it is loaded. I want to rather activate the Storyboard when I change the Visibility of the Image. But I see that Image.Triggers
have to be EventTriggers
.
Which event do I need to hook into?
<Image.Triggers>
<EventTrigger RoutedEvent="Image.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="MandateErrorImage"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.1" Duration="0:0:0.5"
AutoReverse="True" RepeatBehavior="0:0:2" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
If you want to animate on a
DependencyProperty
or bound value you will need to create aStyle
for your image and put the animation in the style.The following
Style
will perform your animation when theVisibility
of your image is set toVisible
:In WPF there is an event
UIElement.IsVisibleChanged
but is a CLR event, not a routed event, therefore inEventTrigger
can not be used.In this case use
IsVisible
property inDataTrigger
like this: