尝试从推送页面导航回来时出现错误
System.ArgumentException: 'Ambiguous routes matched for: //D_FAULT_TabBar14/IMPL_BooksPage/BooksPage/D_FAULT_ModalReader16 matches found: //D_FAULT_TabBar14/IMPL_BooksPage/BooksPage/D_FAULT_ModalReader16,//D_FAULT_TabBar14/IMPL_BooksPage/BooksPage/D_FAULT_ModalReader16 (Parameter 'uri')'
我正在使用 Shell 导航
<TabBar
Shell.NavBarIsVisible="False"
Shell.TabBarBackgroundColor="{DynamicResource Background}"
Shell.TabBarForegroundColor="{DynamicResource HighlightedItem}"
Shell.TabBarTitleColor="{DynamicResource HighlightedItem}"
Shell.TabBarUnselectedColor="{DynamicResource DarkerBackground}">
<ShellContent
Title="წიგნები"
ContentTemplate="{DataTemplate pages:BooksPage}"
Icon="open_book.svg"
Route="BooksPage" />
......
从 BooksPage 然后我像这样转到 Reader
ModalReader mr = new ModalReader(book);
await Shell.Current.Navigation.PushAsync(mr, true);
从阅读器到书签
BookmarksModal bm = new BookmarksModal(_viewModel.Book?.Title ?? "usaxelo", _viewModel.Sarchevi, (int x) =>
{
Carousel.ScrollTo(x, animate: false);
});
await Shell.Current.Navigation.PushAsync(bm, true);
当我尝试弹出时,会抛出一个异常
await Shell.Current.Navigation.PopAsync();
我做错了什么?
注册了路由和依赖项,但仍然出现相同的错误
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute(nameof(Authenticator), typeof(Authenticator));
Routing.RegisterRoute(nameof(MainPage), typeof(MainPage));
Routing.RegisterRoute(nameof(LoginPage), typeof(LoginPage));
Routing.RegisterRoute(nameof(BooksPage), typeof(BooksPage));
//Routing.RegisterRoute(nameof(ReaderPage), typeof(ReaderPage));
//Routing.RegisterRoute(nameof(ProfilePage), typeof(ProfilePage));
//Routing.RegisterRoute("books/modalReader", typeof(ModalReader));
//Routing.RegisterRoute("books/searchPage", typeof(BooksSeachPage));
//Routing.RegisterRoute("books/reader/bookmarks", typeof(BookmarksModal));
//Routing.RegisterRoute("books/reader/font", typeof(FontModal));
}
builder.Services.AddTransient<SessionManagement>();
builder.Services.AddSingleton<MainPage>();
builder.Services.AddSingleton<Authenticator>();
builder.Services.AddSingleton<LoginPage>();
builder.Services.AddSingleton<BooksPage>();
//builder.Services.AddTransient<ReaderPage>();
//builder.Services.AddTransient<ProfilePage>();
//builder.Services.AddTransient<ModalReader>();
//builder.Services.AddTransient<BookmarksModal>();
//builder.Services.AddTransient<FontModal>();
来自医生
如果检测到重复的路由,应用程序启动时将抛出 ArgumentException。如果层次结构中同一级别的两个或多个路由共享一个路由名称,也会引发此异常。
您已经在 Shell 视觉层次结构中注册了 BooksPage 的路由
<ShellContent
Title="წიგნები"
....
Route="BooksPage" />
所以你不必在后面的代码中再次注册它,只需删除这个即可,
Routing.RegisterRoute(nameof(BooksPage), typeof(BooksPage));
更多信息请参考路线