好吧,我有两个与动画有关的问题。
1) 下面的代码不会为标题和边框设置动画,我像 this.FadeIn() 一样调用下面的代码,这当然是 UIElement 类型。
public static void FadeIn(this UIElement targetControl)
{
DoubleAnimation fadeInAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(1.5)));
Storyboard.SetTarget(fadeInAnimation, targetControl);
Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(UIElement.OpacityProperty));
Storyboard sb = new Storyboard();
sb.Children.Add(fadeInAnimation);
sb.Begin();
}
2)这也不起作用,没有动画显示。
public static void SkewAnimation(this UIElement targetControl)
{
DoubleAnimation skewAnimation = new DoubleAnimation(0, 360, new Duration(TimeSpan.FromSeconds(3)));
Storyboard.SetTarget(skewAnimation, targetControl);
Storyboard.SetTargetProperty(skewAnimation, new PropertyPath(SkewTransform.AngleXProperty));
Storyboard sb = new Storyboard();
sb.Children.Add(skewAnimation);
sb.Begin();
}