嗯,我有两个问题都与动画有关。动画无法在Wpf中工作
1)以下代码不会为tittle和border设置动画效果,我会像这样调用以下代码.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();
}
当你说this.FadeIn(),你的意思是你是用它作为类型的UIElement的扩展方法?那是对的吗? – Landern 2012-08-09 16:35:37
是的,我使用这个作为扩展方法 – Haider 2012-08-09 16:40:05