下面的代码在Silverlight中正常工作:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Storyboard storyboard = new Storyboard();
DoubleAnimation doubleAnimation = new DoubleAnimation();
doubleAnimation.From = 50;
doubleAnimation.To = 100;
doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
doubleAnimation.AutoReverse = true;
doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200));
storyboard.Children.Add(doubleAnimation);
Storyboard.SetTarget(doubleAnimation, button1);
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Width"));
storyboard.Begin();
}
在WinRT的/地铁,它需要一个小的改动,使其编译:
Storyboard.SetTargetProperty(doubleAnimation, "Width");
但是当你运行它,什么都不会发生。
如果从“宽”到“不透明度”更改属性(也改变从= 0,为= 1)的作品。
什么是“宽”的问题?