private void AnimateAngle(PiePiece pPiePiece, DependencyProperty pDependencyProperty, double pAngle, EventHandler pEventHandler = null) { double oldAngle = (double)pPiePiece.GetValue(pDependencyProperty); DoubleAnimation animation = new DoubleAnimation(oldAngle, pAngle, new Duration(TimeSpan.FromMilliseconds(IsAnimate ? 500 : 0)), FillBehavior.HoldEnd); animation.EasingFunction = EasingFunction; if (pEventHandler != null) { animation.Completed += pEventHandler; } pPiePiece.BeginAnimation(pDependencyProperty, animation); }