Quantcast
Channel: WPF Animation Help
Viewing all articles
Browse latest Browse all 5

WPF Animation Help

$
0
0

This would be the equivalent, but note you might do better moving the Storyboard to the resources section of the xaml and giving it a key,  then you could just call (if board is the key of the resource):

((Storyboard)this.Resources["name"]).Begin(this);

Nevertheless, here's the answer to the question.

Storyboard board = new Storyboard();

DoubleAnimation transparentStopAnimation = new DoubleAnimation();
transparentStopAnimation.By = 1;
transparentStopAnimation.Duration = new Duration(new TimeSpan(0, 0, 2));
Storyboard.SetTargetName(transparentStopAnimation, "TransparentStop");
Storyboard.SetTargetProperty(transparentStopAnimation, new PropertyPath(GradientStop.OffsetProperty));

DoubleAnimation blackStopAnimation = new DoubleAnimation();
blackStopAnimation.By = 1;
blackStopAnimation.Duration = new Duration(new TimeSpan(0, 0, 2));
blackStopAnimation.BeginTime = new TimeSpan(0, 0, 0, 0, 50);
Storyboard.SetTargetName(blackStopAnimation, "BlackStop");
Storyboard.SetTargetProperty(blackStopAnimation, new PropertyPath(GradientStop.OffsetProperty));

board.Children.Add(transparentStopAnimation);
board.Children.Add(blackStopAnimation);
board.Begin(this);

David Morton - http://blog.davemorton.net/ - @davidmmorton - ForumsBrowser, a WPF Forums Client

Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>