I am currently using .net MAUI 8 and working on trying to get the hardware back button to work using Prism MAUI's navigation service. (version 9.0.401pre). However, I have run into an issue with getting the navigation service working with the hardware and navigation bar back buttons. When either a navigation bar back button is selected, the application exits all together. For my Routes, I have here a paraphrased version of what that routes class file looks like:
public static class Routes
{
public const string LOGIN = "/Login";
public const string HOME = "NavigationPage/Home";
public const string PAGE1 = "Page1";
public const string PAGE2 = "NavigationPage/Page2";
public const string HELP = "NavigationPage/Help";
public const string PAGE3 = "Page3";
public const string PAGE4 = "Page4";
public const string PAGE5 = "NavigationPage/Page5";
public const string PAGE6 = "NavigationPage/Page6";
public const string PAGE7 = "NavigationPage/Page7";
public const string PAGE8 = "Page8";
public const string PAGE8_ABSOLUTE = "NavigationPage/Page8";
public const string PAGE9 = "Page9";
public const string PAGE9_ABSOLUTE = "NavigationPage/Page9";
public const string PAGE10 = "Page10";
public const string PAGE11 = "Page11";
public const string PAGE12 = "Page12";
public const string PAGE13 = "Page13";
public const string PAGE14 = "Page14";
public const string PAGE15 = "Page15";
public const string PAGE16 = "Page16";
public const string PAGE17 = "Page17";
public const string PAGE17_ABSOLUTE = "NavigationPage/Page17";
public const string PAGE18 = "Page18";
public const string PAGE19 = "Page19";
public const string PAGE20 = "Page20";
public const string PAGE21 = "Page21";
public const string PAGE22 = "Page22";
public const string PAGE23 = "Page23";
public const string PAGE24 = "Page24";
public const string PAGE25 = "Page25";
public const string PAGE26 = "Page26";
public const string PAGE27 = "Page27";
public const string PAGE28 = "Page28";
public const string PAGE29 = "Page29";
}
All of these route constants then get funneled into a series of extension methods that branch off of the Prism PageNavigationService, of which, perform a specific type of navigation from the designated page that the routes are called on (these extension methods are simplified for easier reading)
public static async Task TryNavigateAsync(this Prism.Navigation.INavigationService navigationService, string route, string key, object value)
{
var result = await navigationService.CreateBuilder()
.AddSegment(route)
.WithParameters(new Prism.Navigation.NavigationParameters { { key, value } })
.NavigateAsync();
HandleNavigationResult(result);
}
public static async Task TryNavigateWithNavPageAsync(this Prism.Navigation.INavigationService navigationService, string route, string key, object value)
{
var result = await navigationService.CreateBuilder()
.AddSegment(route)
.WithParameters(new Prism.Navigation.NavigationParameters { { key, value } })
.NavigateAsync();
HandleNavigationResult(result);
}
public static async Task TryNavigateAsync(this Prism.Navigation.INavigationService navigationService, Uri uri, Prism.Navigation.INavigationParameters parameters = null)
{
var result = await navigationService.CreateBuilder()
.AddSegment(uri.ToString())
.WithParameters(parameters)
.NavigateAsync();
HandleNavigationResult(result);
}
public static async Task TryNavigateModallyAsync(this Prism.Navigation.INavigationService navigationService, Uri uri, Prism.Navigation.INavigationParameters parameters = null)
{
var result = await navigationService.CreateBuilder()
.AddSegment(uri.ToString())
.WithParameters(parameters)
.NavigateAsync();
HandleNavigationResult(result);
}
public static async Task TryNavigateAsync(this Prism.Navigation.INavigationService navigationService, string path)
{
var result = await navigationService.CreateBuilder()
.AddSegment(path)
.NavigateAsync();
HandleNavigationResult(result);
}
public static async Task TryNavigateWithNavPageAsync(this Prism.Navigation.INavigationService navigationService, string path)
{
var result = await navigationService.CreateBuilder()
.AddSegment(path)
.NavigateAsync();
HandleNavigationResult(result);
}
public static async Task TryNavigateAsync(this Prism.Navigation.INavigationService navigationService, string path, Prism.Navigation.INavigationParameters parameters)
{
var result = await navigationService.CreateBuilder()
.AddSegment(path)
.WithParameters(parameters)
.NavigateAsync();
HandleNavigationResult(result);
}
public static async Task TryNavigateModallyAsync(this Prism.Navigation.INavigationService navigationService, string path, Prism.Navigation.INavigationParameters parameters = null)
{
var result = await navigationService.CreateBuilder()
.AddSegment(path)
.WithParameters(parameters)
.NavigateAsync();
HandleNavigationResult(result);
}
I am not sure if this issue is due to a bug or an incorrect implementation on my part, so any help regarding this would be greatly appreciated. Thank you.