Triggering animation whenever screen is shown
Posted: 10 Dec 2018, 17:08
I figured out to make a very simple animation. A UI element "bouncing" into the screen.
So far so good. But right now I'm using Border.Loaded to trigger it. Which of course only happens once.
But I'd like this to be triggered everytime I go back to this screen (without having to reload it every time).
I looked through the available events and I couldn't quite find one.
Is there another way to trigger this programmatically perhaps?
Code: Select all
<Border x:Name="MyBorder">
<Border.Triggers>
<EventTrigger RoutedEvent="Border.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
From="-100"
To="0"
Duration="0:0:1"
Storyboard.TargetName="MyBorder"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)"
>
<DoubleAnimation.EasingFunction>
<BackEase Amplitude="0.8" EasingMode="EaseInOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Border.Triggers>
<Border.RenderTransform>
<TranslateTransform X="0" Y="0"/>
</Border.RenderTransform>
<!-- ... -->
</Border>
But I'd like this to be triggered everytime I go back to this screen (without having to reload it every time).
I looked through the available events and I couldn't quite find one.
Is there another way to trigger this programmatically perhaps?