注册路线一览
List of registered routes
我正在开发 Xamarin 应用程序,我想在我的应用程序中使用 Xamarin.Forms.Shell 进行导航(路由)。
您是否知道,在 Shell?
中检索已注册路由列表的方法是什么?
例如,考虑以下 SimpleAppShell
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>
一旦 OnAppearing() 被调用,我想在控制台中得到如下内容:
//tab-bar-item/tab-1/page-1
//tab-bar-item/tab-2/page-2
//tab-bar-item/tab-3/page-3
在 google 中查找此主题后,我还没有找到任何内容。
感谢您的支持。
method exposing route keys为internal
,需要使用反射调用此方法
public SimpleAppShell()
{
InitializeComponent();
RegisterExtraRouting();
BindingContext = this;
MethodInfo getRouteKeysMethodInfo = typeof(Routing).GetMethod("GetRouteKeys", BindingFlags.NonPublic | BindingFlags.Static);
string[] routeKeys = (string[])getRouteKeysMethodInfo.Invoke(null, null);
}
我正在开发 Xamarin 应用程序,我想在我的应用程序中使用 Xamarin.Forms.Shell 进行导航(路由)。 您是否知道,在 Shell?
中检索已注册路由列表的方法是什么?例如,考虑以下 SimpleAppShell
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>
一旦 OnAppearing() 被调用,我想在控制台中得到如下内容:
//tab-bar-item/tab-1/page-1
//tab-bar-item/tab-2/page-2
//tab-bar-item/tab-3/page-3
在 google 中查找此主题后,我还没有找到任何内容。
感谢您的支持。
method exposing route keys为internal
,需要使用反射调用此方法
public SimpleAppShell()
{
InitializeComponent();
RegisterExtraRouting();
BindingContext = this;
MethodInfo getRouteKeysMethodInfo = typeof(Routing).GetMethod("GetRouteKeys", BindingFlags.NonPublic | BindingFlags.Static);
string[] routeKeys = (string[])getRouteKeysMethodInfo.Invoke(null, null);
}