Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 8 - BeginAnimation?

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

Is this a bug or has it been changed?

like image 603
Leonardo C Avatar asked Dec 25 '11 19:12

Leonardo C


1 Answers

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();
like image 55
Mike J Avatar answered Oct 28 '22 23:10

Mike J