Windows 8 - BeginAnimation?

2019-04-24 13:36发布

It seems I can't do myObject.BeginAnimation(dp , animation).

Is this a bug or has it been changed?

1条回答
疯言疯语
2楼-- · 2019-04-24 14:25

You need to use a storyboard. Add your animation to the storyboard and have the storyboard begin the animation.

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();
查看更多
登录 后发表回答