Correct place to register shell page routing?

1.6k Views Asked by At

Where is the correct place to register page route (that is not visible on the flyout menu)?

When page is not visible on the flyout menu, I add it to OnStart method via App.xaml.cs

protected override void OnStart()
{
    Routing.RegisterRoute("RegisterPage", typeof(RegisterPage));
    Routing.RegisterRoute("LoginPage", typeof(LoginPage));
}

When page is visible on the flyout menu, I add page routing like this

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

There are 2 best solutions below

0
On BEST ANSWER

You should register the route before use it.

From the 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

0
On

As mentionned in my comment yesterday From 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:"

So at the end it depends on personal choice as long as it is registered before it is being invoked.

Related question

Bug? System.ArgumentException: 'unable to figure out route for: