private void PrismApplicationBase_ModalPopping(object sender, ModalPoppingEventArgs e) { if (PageNavigationService.NavigationSource == PageNavigationSource.Device) { _previousPage = PageUtilities.GetOnNavigatedToTarget(e.Modal, MainPage, true); } }
/// <summary> /// Navigates to the most recent entry in the back navigation history by popping the calling Page off the navigation stack. /// </summary> /// <param name="parameters">The navigation parameters</param> /// <param name="useModalNavigation">If <c>true</c> uses PopModalAsync, if <c>false</c> uses PopAsync</param> /// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param> /// <returns>If <c>true</c> a go back operation was successful. If <c>false</c> the go back operation failed.</returns> protected virtual async Task <INavigationResult> GoBackInternal(INavigationParameters parameters, bool?useModalNavigation, bool animated) { var result = new NavigationResult(); try { NavigationSource = PageNavigationSource.NavigationService; var page = GetCurrentPage(); var segmentParameters = UriParsingHelper.GetSegmentParameters(null, parameters); segmentParameters.GetNavigationParametersInternal().Add(KnownInternalParameters.NavigationMode, NavigationMode.Back); var canNavigate = await PageUtilities.CanNavigateAsync(page, segmentParameters); if (!canNavigate) { result.Exception = new Exception($"IConfirmNavigation for {page} returned false"); return(result); } bool useModalForDoPop = UseModalNavigation(page, useModalNavigation); Page previousPage = PageUtilities.GetOnNavigatedToTarget(page, _applicationProvider.MainPage, useModalForDoPop); PageUtilities.OnNavigatingTo(previousPage, segmentParameters); await PageUtilitiesExtended.OnNavigatingToAsync(previousPage, segmentParameters); var poppedPage = await DoPop(page.Navigation, useModalForDoPop, animated); if (poppedPage != null) { PageUtilities.OnNavigatedFrom(page, segmentParameters); PageUtilities.OnNavigatedTo(previousPage, segmentParameters); PageUtilities.DestroyPage(poppedPage); result.Success = true; return(result); } } catch (Exception ex) { _logger.Log(ex.ToString(), Category.Exception, Priority.High); result.Exception = ex; return(result); } finally { NavigationSource = PageNavigationSource.Device; } result.Exception = new Exception("Unknown error occured."); return(result); }
/// <summary> /// Navigates to the most recent entry in the back navigation history by popping the calling Page off the navigation stack. /// </summary> /// <param name="parameters">The navigation parameters</param> /// <param name="useModalNavigation">If <c>true</c> uses PopModalAsync, if <c>false</c> uses PopAsync</param> /// <param name="animated">If <c>true</c> the transition is animated, if <c>false</c> there is no animation on transition.</param> /// <returns>If <c>true</c> a go back operation was successful. If <c>false</c> the go back operation failed.</returns> public virtual async Task <bool> GoBackAsync(NavigationParameters parameters = null, bool?useModalNavigation = null, bool animated = true) { try { NavigationSource = PageNavigationSource.NavigationService; var page = GetCurrentPage(); var segmentParameters = UriParsingHelper.GetSegmentParameters(null, parameters); segmentParameters.Add(KnownNavigationParameters.NavigationMode, NavigationMode.Back); var canNavigate = await PageUtilities.CanNavigateAsync(page, segmentParameters); if (!canNavigate) { return(false); } bool useModalForDoPop = UseModalNavigation(page, useModalNavigation); Page previousPage = PageUtilities.GetOnNavigatedToTarget(page, _applicationProvider.MainPage, useModalForDoPop); PageUtilities.OnNavigatingTo(previousPage, segmentParameters); var poppedPage = await DoPop(page.Navigation, useModalForDoPop, animated); if (poppedPage != null) { PageUtilities.OnNavigatedFrom(page, segmentParameters); PageUtilities.OnNavigatedTo(previousPage, segmentParameters); PageUtilities.DestroyPage(poppedPage); return(true); } } catch (Exception e) { _logger.Log(e.ToString(), Category.Exception, Priority.High); return(false); } finally { NavigationSource = PageNavigationSource.Device; } return(false); }