Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin 已登记路线一览表_Xamarin_Xamarin.forms_Xamarin.forms.shell - Fatal编程技术网

Xamarin 已登记路线一览表

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();

我正在开发一个Xamarin应用程序,我想在我的应用程序中使用Xamarin.Forms.Shell进行导航(路由)。 您是否知道,在Shell中检索已注册路由列表的方法是什么

例如,考虑下面的<>代码> 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);
}