maui
maui copied to clipboard
Ambiguous route when PopModalAsync
Description
When calling PopModalAsync, the navigation fails to go back to the calling page.
Ambiguous routes matched for: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage matches found: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage,//IMPL_MainPage/IMPL_MainPage/MainPage/TestPage Arg_ParamName_Name
Steps to Reproduce
- Run reprodution project
- Click "Go to test page"
- Click "Go to choice page"
- Click on a choice
- See unexpected error
Link to public reproduction project repository
https://github.com/sinsedrix/MauiTests/tree/main/Modal
Version with bug
8.0.3 GA
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
- Windows
- Android emulator
Affected platform versions
net8.0-windows10.0.19041.0
Did you find any workaround?
no
Relevant log output
System.ArgumentException
HResult=0x80070057
Message=Ambiguous routes matched for: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage matches found: //IMPL_MainPage/IMPL_MainPage/MainPage/TestPage,//IMPL_MainPage/IMPL_MainPage/MainPage/TestPage Arg_ParamName_Name
Source=Microsoft.Maui.Controls
Arborescence des appels de procédure :
à Microsoft.Maui.Controls.ShellUriHandler.GetNavigationRequest(Shell shell, Uri uri, Boolean enableRelativeShellRoutes, Boolean throwNavigationErrorAsException, ShellNavigationParameters shellNavigationParameters)
à Microsoft.Maui.Controls.ShellNavigationManager.<GoToAsync>d__14.MoveNext()
à Microsoft.Maui.Controls.Shell.NavigationImpl.<OnPopModal>d__10.MoveNext()
à Modal.ShellExt.<PopModalAsync>d__2.MoveNext() dans C:\wk\Tests\MauiTests\Modal\ShellExt.cs :ligne 24
à Modal.ViewModels.BaseModalVm`1.<>c__DisplayClass4_0.<<GetResultAsync>b__0>d.MoveNext() dans C:\wk\Tests\MauiTests\Modal\ViewModels\BaseModalVm.cs :ligne 16
Verified this issue with Visual Studio 17.10.0 preview2 (8.0.14). Can repro on windows and android platforms with sample project.
Any workaround would be welcome...
you have two things registered to "MainPage" https://github.com/sinsedrix/MauiTests/blob/main/Modal/MauiProgram.cs#L22 https://github.com/sinsedrix/MauiTests/blob/main/Modal/AppShell.xaml#L13
I see this same problem without registering the same route twice if I have a base page which opens a page with PushModalAsync (new VM1()) which then opens a different page with PushModalAsync(new VM2) and then that last page attempts to call PopModalAsync()
Ambiguous routes matched for: //IMPL_LocalLAPTOP/IMPL_LocalLAPTOP/LocalLAPTOP/D_FAULT_BrowseDatabasePage14 matches found: //IMPL_LocalLAPTOP/IMPL_LocalLAPTOP/LocalLAPTOP/D_FAULT_BrowseDatabasePage14,//IMPL_LocalLAPTOP/IMPL_LocalLAPTOP/LocalLAPTOP/D_FAULT_BrowseDatabasePage14 (Parameter 'uri')
you have two things registered to "MainPage" https://github.com/sinsedrix/MauiTests/blob/main/Modal/MauiProgram.cs#L22 https://github.com/sinsedrix/MauiTests/blob/main/Modal/AppShell.xaml#L13
Could you check it?
I run into the same issue if I navigate to a page using Application.Current.MainPage.Navigation.PushAsync(page); and then call await Shell.Current.Navigation.PopAsync(); trying to go back. This page is not registered in my AppShell.xaml because I don't want it showing up in the main navigation. If I register the route and set IsVisible to false, it can't find the route and crashes.