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
C# 注册外壳页路由的正确位置?_C#_Xamarin_Xamarin.forms_Xamarin.forms.shell - Fatal编程技术网

C# 注册外壳页路由的正确位置?

C# 注册外壳页路由的正确位置?,c#,xamarin,xamarin.forms,xamarin.forms.shell,C#,Xamarin,Xamarin.forms,Xamarin.forms.shell,哪里是注册页面路由的正确位置(在弹出式菜单上不可见) 当页面在弹出菜单上不可见时,我通过App.xaml.cs将其添加到OnStart方法中 protected override void OnStart() { Routing.RegisterRoute("RegisterPage", typeof(RegisterPage)); Routing.RegisterRoute("LoginPage", typeof(LoginPage));

哪里是注册页面路由的正确位置(在弹出式菜单上不可见)

当页面在弹出菜单上不可见时,我通过App.xaml.cs将其添加到
OnStart
方法中

protected override void OnStart()
{
    Routing.RegisterRoute("RegisterPage", typeof(RegisterPage));
    Routing.RegisterRoute("LoginPage", typeof(LoginPage));
}
当页面在弹出菜单上可见时,我会像这样添加页面路由

<FlyoutItem Title="Home" Icon="icon_home.png">
    <ShellContent Route="HomePage" ContentTemplate="{DataTemplate local:HomePage}" />
</FlyoutItem>

在使用路线之前,您应该先注册路线

从:

在Shell子类构造函数中,或运行的任何其他位置 在调用路由之前,可以显式地调用其他路由 已注册任何未在Shell visual Studio中表示的页面 等级制度

正如我在报告中提到的 发件人:

在Shell子类构造函数中,或在调用路由之前运行的任何其他位置,可以为Shell可视层次结构中未表示的任何页面显式注册其他路由:

因此,最终它取决于个人选择,只要在调用它之前注册即可

相关问题

From“在Shell子类构造函数中,或在调用路由之前运行的任何其他位置,可以为Shell可视化层次结构中未表示的任何页面显式注册其他路由:“如果您意外注册了一个页面两次,会发生什么情况?我相信即使使用两个不同的路由,也不会发生任何情况,但这不包括在问题中。