我正在使用 StoryBoard API 在 Windows Store 应用程序中为画布制作动画:
DoubleAnimation widthAnimation = new DoubleAnimation();
DoubleAnimation heightAnimation = new DoubleAnimation();
widthAnimation.BeginTime = new TimeSpan(0, 0, 0, 0, outDuration + inDuration);
heightAnimation.BeginTime = new TimeSpan(0, 0, 0, 0, outDuration + inDuration);
widthAnimation.Duration = new TimeSpan(0, 0, 0, 0, collapseDuration);
heightAnimation.Duration = new TimeSpan(0, 0, 0, 0, collapseDuration);
Storyboard.SetTarget(widthAnimation, target);
Storyboard.SetTargetProperty(widthAnimation, "Width");
Storyboard.SetTarget(heightAnimation, target);
Storyboard.SetTargetProperty(heightAnimation, "Height");
widthAnimation.From = beginSize.Width;
widthAnimation.To = endSize.Width;
heightAnimation.From = beginSize.Height;
heightAnimation.To = endSize.Height;
Storyboard stb = new Storyboard();
stb.Children.Add(widthAnimation);
stb.Children.Add(heightAnimation);
stb.Begin();
但是宽度和高度动画不起作用。有关如何解决它的任何指示?