Last active
October 9, 2018 22:57
-
-
Save nasal/c6585806ace571b18745 to your computer and use it in GitHub Desktop.
XAML: Fade in and out animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Invoke with ((Storyboard)FindResource("FadeInOut")).Begin(ControlName); --> | |
<ResourceDictionary> | |
<Storyboard x:Key="FadeInOut"> | |
<!-- If the element has Visibility="Hidden". --> | |
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetProperty="Visibility"> | |
<DiscreteObjectKeyFrame KeyTime="0"> | |
<DiscreteObjectKeyFrame.Value> | |
<Visibility>Visible</Visibility> | |
</DiscreteObjectKeyFrame.Value> | |
</DiscreteObjectKeyFrame> | |
</ObjectAnimationUsingKeyFrames> | |
<!-- Endif. --> | |
<!-- If the element is hidden with Opacity="0.0". You need the following two lines in any case. --> | |
<DoubleAnimation BeginTime="0:0:0.0" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="0:0:0.5"/> | |
<DoubleAnimation BeginTime="0:0:2.5" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="0:0:0.5"/> | |
<!-- If you want to re-set Visibility="Hidden". --> | |
<ObjectAnimationUsingKeyFrames BeginTime="0:0:3.0" Storyboard.TargetProperty="Visibility"> | |
<DiscreteObjectKeyFrame KeyTime="0"> | |
<DiscreteObjectKeyFrame.Value> | |
<Visibility>Hidden</Visibility> | |
</DiscreteObjectKeyFrame.Value> | |
</DiscreteObjectKeyFrame> | |
</ObjectAnimationUsingKeyFrames> | |
<!-- Endif. --> | |
</Storyboard> | |
</ResourceDictionary> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment