xamarin - 无法使用 Prism Navigation 在 TabbedPage 中打开特定页面
问题描述
我的应用程序中有一个带有两个选项卡的 TabbedPage,我想使用 NavigateAsync 导航到特定选项卡,但是当我使用 NavigationService.NavigateAsync(“NavigationPage/TabbedPage/SelectedPage”)时,我的应用程序只打开堆栈中带有 TabbedPage 的 SelectedPage。我可以单击 SelectedPage 中的返回按钮返回到 TabbedPage。
有谁知道出了什么问题?
这是我的 TabbedPage axml:
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="correct namespace was hide"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="correct namespace was hide">
<TabbedPage.Children>
<local:Pacientes/>
<local:Sobre/>
</TabbedPage.Children>
</TabbedPage>
这是我在 App 类中的 OnInitialized 方法和 RegisterTypes:
protected override async void OnInitialized()
{
InitializeComponent();
if (Device.RuntimePlatform.Equals(Device.Android))
{
await NavigationService.NavigateAsync("Android.Main/OdontoWayPacienteNavigation/Sobre");
}
else
{
await NavigationService.NavigateAsync("/NavigationPage/iOS.Main/Sobre");
}
}
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
containerRegistry.RegisterForNavigation<OdontoWayPacienteNavigation>();
containerRegistry.RegisterForNavigation<NavigationPage>();
containerRegistry.RegisterForNavigation<Pacientes>();
containerRegistry.RegisterForNavigation<Clinicas>();
containerRegistry.RegisterForNavigation<PacienteEdit>();
containerRegistry.RegisterForNavigation<ClinicaMap>();
containerRegistry.RegisterForNavigation<LinkWeb>();
containerRegistry.RegisterForNavigation<Sobre>();
containerRegistry.RegisterForNavigation<Views.Android.PacienteAcessos, PacienteAcessosViewModel>("Android.PacienteAcessos");
containerRegistry.RegisterForNavigation<Views.iOS.PacienteAcessos, PacienteAcessosViewModel>("iOS.PacienteAcessos");
containerRegistry.RegisterForNavigation<Views.Android.Main, MainViewModel>("Android.Main");
containerRegistry.RegisterForNavigation<Views.iOS.Main>("iOS.Main");
}
解决方案
解决方案发布在此链接https://forums.xamarin.com/discussion/comment/330770#Comment_330770
导航的行为在 prism 版本 7 中发生了变化。打开特定选项卡的新行为是
NavigateAsync("TabbedPage?selectedTab=PageName")
推荐阅读
- java - 如何获取在 spring 中注册的所有转换器和格式化程序?
- php - PHP 使用具有两个不同输入的一个表单将两种不同的文件类型上传到两个不同的目录中
- google-oauth - HTTP 请求未使用客户端身份验证方案未经授权匿名,从服务器收到的身份验证标头是 OAuth 领域
- python - Google App Engine Python:部署时 yaml 配置文件出错
- python - ZeroMQ 同步 PUB-SUB:订阅者同步挂起,但正常工作
- android - 如何在 AndroidX 或 Android 支持库中使用 (.).media.tv.Program?
- python - Keras - 如何将 LSTM 代码转换为 CNN
- java - 根据给定java的位置更改数组中的元素
- python - Python Iterator - For i in [something]
- java - Spring中的JSON ObjectMapper - 如何将JSON映射到三个类?