Skip to content
craigomatic edited this page Oct 14, 2014 · 1 revision

Single page apps behave a little differently when wrapped as they will only ever cause the Navigated (or LoadCompleted on WP8) event to fire once. Subsequent routing will instead cause the FrameContentLoading event to fire.

To map actions to these routes, a RouteTiming overload is available in the Map method of the WebRoute class:

private void WebHost_Ready(object sender, EventArgs e)
{
    WebHost.WebRoute.Map("/", async (uri, success, errorCode) =>
    {
        System.Diagnostics.Debug.WriteLine(uri.ToString());

    }, false, RouteTiming.FrameContentLoading);
}

Note that in the above, the RouteTiming.FrameContentLoading property is specified as the final overload to the Map method.

Using this approach allows the developer to customise the UI based on the route, for example to display a Pin button in the AppBar on pages that match a specific route.