Xamarin 已登记路线一览表
我正在开发一个Xamarin应用程序,我想在我的应用程序中使用Xamarin.Forms.Shell进行导航(路由)。 您是否知道,在Shell中检索已注册路由列表的方法是什么Xamarin 已登记路线一览表,xamarin,xamarin.forms,xamarin.forms.shell,Xamarin,Xamarin.forms,Xamarin.forms.shell,我正在开发一个Xamarin应用程序,我想在我的应用程序中使用Xamarin.Forms.Shell进行导航(路由)。 您是否知道,在Shell中检索已注册路由列表的方法是什么 例如,考虑下面的代码> SimuleAppSt/ /P> public partial class SimpleAppShell : Xamarin.Forms.Shell { public SimpleAppShell() { InitializeComponent();
例如,考虑下面的<>代码> SimuleAppSt/<代码> /P>
public partial class SimpleAppShell : Xamarin.Forms.Shell
{
public SimpleAppShell()
{
InitializeComponent();
RegisterExtraRouting();
BindingContext = this;
}
protected void RegisterExtraRouting()
{
Routing.RegisterRoute("//tab-bar-item/tab-2/page-2", typeof(ContentPage2));
Routing.RegisterRoute("//tab-bar-item/tab-3/page-3", typeof(ContentPage3));
}
public override OnAppearing()
{
base.OnAppearing();
PrintMyRoutes(); // TODO: don't know where to get the info from
}
}
下面的XAML文件与上面的Shell
相关
<!--- removed config code for simplicity -->
<TabBar
Route="tab-bar-item">
<Tab
Title="Tab-1"
Route="tab-1"
Icon="tabs_icon.png">
<ShellContent
Route="page-1"
ContentTemplate="{DataTemplate local:ContentPage1}" />
</Tab>
</TabBar>
在谷歌上搜索这个主题后,我还没有找到任何东西
感谢您的支持。是内部的方法,您需要使用反射来调用此方法
public SimpleAppShell()
{
InitializeComponent();
RegisterExtraRouting();
BindingContext = this;
MethodInfo getRouteKeysMethodInfo = typeof(Routing).GetMethod("GetRouteKeys", BindingFlags.NonPublic | BindingFlags.Static);
string[] routeKeys = (string[])getRouteKeysMethodInfo.Invoke(null, null);
}
public SimpleAppShell()
{
InitializeComponent();
RegisterExtraRouting();
BindingContext = this;
MethodInfo getRouteKeysMethodInfo = typeof(Routing).GetMethod("GetRouteKeys", BindingFlags.NonPublic | BindingFlags.Static);
string[] routeKeys = (string[])getRouteKeysMethodInfo.Invoke(null, null);
}