Created
January 6, 2015 11:48
-
-
Save nasal/4ada380fcf4c8032f1fe to your computer and use it in GitHub Desktop.
C#: Fade 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
var myControl = ControlName; | |
var a = new DoubleAnimation | |
{ | |
From = 1.0, | |
To = 0.0, | |
FillBehavior = FillBehavior.Stop, | |
BeginTime = TimeSpan.FromSeconds(2), | |
Duration = new Duration(TimeSpan.FromSeconds(0.5)) | |
}; | |
var storyboard = new Storyboard(); | |
storyboard.Children.Add(a); | |
Storyboard.SetTarget(a, myControl); | |
Storyboard.SetTargetProperty(a, new PropertyPath(OpacityProperty)); | |
storyboard.Completed += delegate { myControl.Visibility = Visibility.Hidden; }; | |
storyboard.Begin(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment