注册 shell 页面路由的正确位置?
Correct place to register shell page routing?
注册页面路由的正确位置在哪里(在弹出菜单中不可见)?
当页面在弹出菜单上不可见时,我通过 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>
您应该在使用之前注册该路线。
来自document:
In the Shell subclass constructor, or any other location that runs
before a route is invoked, additional routes can be explicitly
registered for any pages that aren't represented in the Shell visual
hierarchy
正如我在 中提到的
来自 Shell.Navigation:
"In the Shell subclass constructor, or any other location that runs before a route is invoked, additional routes can be explicitly registered for any pages that aren't represented in the Shell visual hierarchy:"
所以最后看个人选择只要在调用前先注册即可.
相关问题
注册页面路由的正确位置在哪里(在弹出菜单中不可见)?
当页面在弹出菜单上不可见时,我通过 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>
您应该在使用之前注册该路线。
来自document:
In the Shell subclass constructor, or any other location that runs before a route is invoked, additional routes can be explicitly registered for any pages that aren't represented in the Shell visual hierarchy
正如我在
"In the Shell subclass constructor, or any other location that runs before a route is invoked, additional routes can be explicitly registered for any pages that aren't represented in the Shell visual hierarchy:"
所以最后看个人选择只要在调用前先注册即可.