Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Maui/Prism.Maui/Navigation/PageNavigationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Prism.Events;
using Prism.Extensions;
using Prism.Mvvm;
using Prism.Navigation.Regions;
using Application = Microsoft.Maui.Controls.Application;
using XamlTab = Prism.Navigation.Xaml.TabbedPage;

Expand Down Expand Up @@ -100,7 +101,9 @@ private async Task<INavigationResult> GoBackInternalAsync(INavigationParameters

page = GetCurrentPage();
if (IsRoot(GetPageFromWindow(), page))
throw new NavigationException(NavigationException.CannotPopApplicationMainPage, page);
{
return SendAppToBackground(page);
}

parameters.GetNavigationParametersInternal().Add(KnownInternalParameters.NavigationMode, NavigationMode.Back);

Expand Down Expand Up @@ -1255,6 +1258,18 @@ internal static bool UseReverseNavigation(Page currentPage, Type nextPageType)
return MvvmHelpers.HasNavigationPageParent(currentPage) && MvvmHelpers.IsSameOrSubclassOf<ContentPage>(nextPageType);
}

private INavigationResult SendAppToBackground(Page page)
{
#if ANDROID
MauiAppCompatActivity activity = Window.Handler.PlatformView as MauiAppCompatActivity;
activity.MoveTaskToBack(true);

return new NavigationResult();
#else
throw new NavigationException(NavigationException.CannotPopApplicationMainPage, page);
#endif
}

private INavigationResult Notify(NavigationRequestType type, INavigationParameters parameters, Exception exception = null)
{
var result = new NavigationResult(exception);
Expand Down