Wow, this has not been updated for a long time ... just in case someone tracks this:
The problem is that you do not wait for the flip front animation to complete before you start to lean back - now, since you basically compress the Y-angle animation right away to 90 degrees, so it doesn't seem to shoot properly way.
There are many ways you can get around this: the first thing that comes to mind is that DoubleAnimation has a CreateClock method on them that will return an AnimationClock object to you. This object has a Completed event that will tell you when this animation will be completed. Attach a handler (remember that you will want to detach it so that you do not leak into the memory), and call the "start dumping back" method. I threw something very inefficient together, but it will show the principle:
public AnimationClock StartFlipFrontAnimation() { this.ImageFace.Source = _frontFace; DoubleAnimation flipfront = new DoubleAnimation(0, 90, new Duration(new TimeSpan(0, 0, 3))); SkewTransform skew = new SkewTransform(); this.RenderTransform = skew; skew.BeginAnimation(SkewTransform.AngleYProperty, flipfront); return flipfront.CreateClock(); } public AnimationClock StartFlipBackAnimation() { this.ImageFace.Source = _backFace; DoubleAnimation flipfront = new DoubleAnimation(90, 0, new Duration(new TimeSpan(0, 0, 3))); SkewTransform skew = new SkewTransform(); this.RenderTransform = skew; skew.BeginAnimation(SkewTransform.AngleYProperty, flipfront); return flipfront.CreateClock(); } public void BeginFlip() { var frontClk = StartFlipFrontAnimation(); frontClk.Completed += FrontFlipDone; } private void FrontFlipDone(object sender, EventArgs args) { var clk = sender as AnimationClock; if(clk != null) { clk.Completed -= FrontFlipDone; } var backClk = StartFlipBackAnimation(); }
source share