private void AddAnimationToStoryBoard(object view, Storyboard storyBoard, DoubleAnimationUsingKeyFrames animationKeyFrames, AnimationOrientation orientation) { if (orientation == AnimationOrientation.Horizontal) { Storyboard.SetTargetProperty(animationKeyFrames, "(UIElement.Projection).(PlaneProjection.GlobalOffsetX)"); } else if (orientation == AnimationOrientation.Vertical) { Storyboard.SetTargetProperty(animationKeyFrames, "(UIElement.Projection).(PlaneProjection.GlobalOffsetY)"); } (view as UIElement).Projection = new PlaneProjection() { GlobalOffsetY = 0, GlobalOffsetX = 0 }; Storyboard.SetTarget(animationKeyFrames, view as UIElement); storyBoard.Children.Add(animationKeyFrames); }
public SimpleAnimation(FrameworkElement frameworkElement, TimeSpan length, double startPosition, double endPosition, AnimationType animationType, AnimationOrientation orientation, Action <object> actionAfterStopsWithAttachedElement) { AtachedFrameworkElement = frameworkElement; AnimationStoryBoard = new Storyboard(); _actionAfterStops = actionAfterStopsWithAttachedElement; DoubleAnimationUsingKeyFrames animationKeyFramesNewView = AddKeyFrame(endPosition, startPosition, TimeSpan.FromMilliseconds(0), length); AddAnimationToStoryBoard(AtachedFrameworkElement, AnimationStoryBoard, animationKeyFramesNewView, orientation); }