From 842ab9aa1891eb6ad1b1b7bfe72ca3130e5ea588 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Fri, 27 Jan 2023 06:13:01 -0600 Subject: [PATCH 1/5] Blazor Hybrid (MAUI) page-component navigation --- aspnetcore/blazor/hybrid/routing.md | 125 ++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 6 deletions(-) diff --git a/aspnetcore/blazor/hybrid/routing.md b/aspnetcore/blazor/hybrid/routing.md index 2495cf40957c..85a98d246545 100644 --- a/aspnetcore/blazor/hybrid/routing.md +++ b/aspnetcore/blazor/hybrid/routing.md @@ -13,6 +13,8 @@ zone_pivot_groups: blazor-hybrid-frameworks This article explains how to manage request routing and navigation in Blazor Hybrid apps. +## URI request routing behavior + Default URI request routing behavior: * A link is *internal* if the host name and scheme match between the app's origin URI and the request URI. When the host names and schemes don't match or if the link sets `target="_blank"`, the link is considered *external*. @@ -35,13 +37,11 @@ The -* WPF: -* Windows Forms: - -## Namespace +* .NET MAUI: +* WPF: +* Windows Forms: -The namespace is required for the examples in this article: +The namespace is required for the following examples: ```csharp using Microsoft.AspNetCore.Components.WebView; @@ -109,3 +109,116 @@ blazorWebView.UrlLoading += ``` :::zone-end + +:::zone pivot="maui" + +## Navigation among pages and Razor components + +This section explains how to navigate among .NET MAUI content pages and Razor components. + +The .NET MAUI Blazor hybrid project template isn't a [Shell-based app](/dotnet/maui/fundamentals/shell/), so the [URI-based navigation for Shell-based apps](/dotnet/maui/fundamentals/shell/navigation) isn't the simplest approach to implement in a project based on the project template. The examples in this section use a to perform modeless or modal navigation. + +In the following example: + +* The namespace of the app is `MauiBlazor`, which matches the suggested project name of the tutorial. +* A is placed in a new folder added to the app named `Views`. + +In `App.xaml`, create the `MainPage` as a by making the following change: + +```diff +- MainPage = new MainPage(); ++ MainPage = new NavigationPage(new MainPage()); +``` + +`Views/NavigationExample.xaml`: + +```xaml + + +