synchronous animation
I have something this:
scaleTransform.BeginAnimation(ScaleTransform.ScaleXProperty, shrinkAnimation);
scaleTransform.BeginAnimation(ScaleTransform.ScaleYProperty, shrinkAnimation);
MyDialog.Show();
The animations run correctly in parallel (x and y shrink together), but because BeginAnimation
is an asynchronous call, the Show()
method gets executed while the animation is still running (suppose shrinkAnimation
runs for 1 second).
How can I wait for animations to complete before calling Show()
?
Thanks!
You can use a Storyboard
, which has a completed event, instead of that BeginAnimation
method. Here's an example, setting opacity, but it's the same concept:
DoubleAnimation animation = new DoubleAnimation(0.0, new Duration(TimeSpan.FromSeconds(1.0)));
Storyboard board = new Storyboard();
board.Children.Add(animation);
Storyboard.SetTarget(animation, MyButton);
Storyboard.SetTargetProperty(animation, new PropertyPath("(Opacity)"));
board.Completed += delegate
{
MessageBox.Show("DONE!");
};
board.Begin();
链接地址: http://www.djcxy.com/p/44572.html
上一篇: 使用a.vim for C ++
下一篇: 同步动画