Microsoft.Phone.Controls.TransitionFrame.OnNavigating C# (CSharp) Method

OnNavigating() private method

Handles the Navigating event of the frame, the immediate way to begin a transition out before the new page has loaded or had its layout pass.
private OnNavigating ( object sender, System.Windows.Navigation.NavigatingCancelEventArgs e ) : void
sender object The source object.
e System.Windows.Navigation.NavigatingCancelEventArgs The event arguments.
return void
        private void OnNavigating(object sender, NavigatingCancelEventArgs e)
        {
            // If the current application is not the origin
            // and destination of the navigation, ignore it.
            // e.g. do not play a transition when the 
            // application gets deactivated because the shell
            // will animate the frame out automatically.
            if (!e.IsNavigationInitiator)
            {
                return;
            }

            _isForwardNavigation = e.NavigationMode != NavigationMode.Back;

            var oldElement = Content as UIElement;
            if (oldElement == null)
            {
                return;
            }

            EnsureLastTransitionIsComplete();

            FlipPresenters();

            TransitionElement oldTransitionElement = null;
            NavigationOutTransition navigationOutTransition = null;
            ITransition oldTransition = null;

            navigationOutTransition = TransitionService.GetNavigationOutTransition(oldElement);

            if (navigationOutTransition != null)
            {
                oldTransitionElement = _isForwardNavigation ? navigationOutTransition.Forward : navigationOutTransition.Backward;
            }
            if (oldTransitionElement != null)
            {
                oldTransition = oldTransitionElement.GetTransition(oldElement);
            }
            if (oldTransition != null)
            {
                EnsureStoppedTransition(oldTransition);

                _storedNavigationOutTransition = navigationOutTransition;
                _storedOldTransition = oldTransition;
                oldTransition.Completed += OnExitTransitionCompleted;

                _performingExitTransition = true;

                PerformTransition(navigationOutTransition, _oldContentPresenter, oldTransition);

                PrepareContentPresenterForCompositor(_oldContentPresenter);
            }
            else
            {
                _readyToTransitionToNewContent = true;
            }
        }