/// <summary>
        /// Called when the <c>Navigated</c> event is invoked.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="NavigationEventArgs"/> instance containing the event data.</param>
        /// <remarks>
        /// This method is public due to the fact that weak events are used. Otherwise, the navigation completed events
        /// could not be handled (because we unsubscribed from the RootFrame) when navigating away to prevent memory
        /// leaks.
        /// <para />
        /// Please, do not call this method yourself, otherwise you can seriously ruin your apps.
        /// </remarks>
        public void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            if (!CanHandleNavigation)
            {
                return;
            }

            if (!CanHandleNavigationAdvanced())
            {
                return;
            }

            // If this navigation event is not meant for this page, exit
            if (!e.IsNavigationForView(TargetControlType))
            {
                return;
            }

            HasHandledSaveAndCancelLogic = false;

            if (_hasNavigatedButNotNavigatedAway)
            {
                return;
            }

            _hasNavigatedButNotNavigatedAway = true;

            if (e.Uri != null && e.Uri.ToString().Contains("app://external"))
            {
                Log.Debug("Navigating away from the application, ignoring navigation");
                return;
            }

            OnNavigated(e);

#if NETFX_CORE
            var navigationContext = e.Parameter;
#elif WINDOWS_PHONE
            var navigationContext = ((PhoneApplicationPage)TargetControl).NavigationContext;
#elif SILVERLIGHT
            var navigationContext = e.Content;
#else
            var navigationContext = e.ExtraData;
#endif

            HandleNavigated(navigationContext);
        }
Example #2
0
        private void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            // CTL-906: clear current navication context if (re) navigating to the same view
            if (e.IsNavigationForView(NavigationTargetType))
            {
                _lastNavigationContext = null;
            }

            var sourceDictionary = e.ExtraData as Dictionary <string, object>;

            if (sourceDictionary == null)
            {
                sourceDictionary            = new Dictionary <string, object>();
                sourceDictionary["context"] = e.ExtraData;
            }

            _lastGlobalNavigationContext = sourceDictionary;

            var eventArgs = new NavigatedEventArgs(e.Uri.ToString(), NavigationMode.Unknown);

            HandleNavigatedEvent(eventArgs);
        }