Exemplo n.º 1
0
        public void NavigateBack(FrameAnimationBase animation = null)
        {
            if (Container.Children.Count == 0)
            {
                throw new InvalidOperationException("There is no current element being displayed!");
            }
            if (elementStack.Count == 0)
            {
                throw new InvalidOperationException("Cannot navigate back as there are no more elements in the stack!");
            }

            if (animating)
            {
                return;
            }

            FrameworkElement currentChild = Container.Children[0] as FrameworkElement;
            FrameworkElement newChild     = elementStack.Pop();

            Container.Children.Add(newChild);
            if (animation != null)
            {
                animating = true;
                animation.AnimationEnded += FrameNavigation_AnimationEnded;
                (animation as IFrameAnimation).Start(currentChild, newChild, Container);
            }
            else
            {
                FrameNavigation_AnimationEnded(null, new FrameAnimationBase.AnimationEndedArgs(currentChild, newChild));
            }
        }
Exemplo n.º 2
0
        public void NavigateTo(FrameworkElement element, FrameAnimationBase animation = null)
        {
            if (element is null)
            {
                throw new ArgumentNullException($"{nameof(element)} cannot be null!");
            }

            if (animating)
            {
                return;
            }

            FrameworkElement previousChild = Container.Children.Count == 0 ? null : Container.Children[0] as FrameworkElement;
            FrameworkElement newChild      = element;

            Container.Children.Add(newChild);

            if (previousChild != null)
            {
                elementStack.Push(previousChild);
            }
            if (animation != null)
            {
                animating = true;
                animation.AnimationEnded += FrameNavigation_AnimationEnded;
                (animation as IFrameAnimation).Start(previousChild, newChild, Container);
            }
            else
            {
                FrameNavigation_AnimationEnded(null, new FrameAnimationBase.AnimationEndedArgs(previousChild, newChild));
            }
        }