Windows 8 - BeginAnimation?

时间:2011-12-25 19:11:06

标签: c# windows-8 windows-runtime microsoft-metro

我似乎无法做myObject.BeginAnimation(dp , animation)

这是一个错误还是已被更改?

1 个答案:

答案 0 :(得分:7)

您需要使用故事板。将动画添加到故事板并让故事板开始动画。

var storyboard = new Storyboard();

var opacityAnimation = new DoubleAnimation { 
    From = 0,
    To = 1,
    Duration = DurationHelper.FromTimeSpan(TimeSpan.FromSeconds(1)),
};
storyboard.Children.Add(opacityAnimation);

Storyboard.SetTargetProperty(opacityAnimation, "Opacity");
Storyboard.SetTarget(storyboard, myObject);

storyboard.Begin();