Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

In a Blazor Hybrid App. How do I set the initial page inside the webview while still using the layout

$
0
0

In the MainLayout.razor page you have a @body which will by default show the control with a @page "/" at the top. I would like to dynamically set it to this page or a different page depending on custom logic.

If I try to set the page at the BlazorWebView control (in MainPage.xaml) it will then show the page but without the layout (MainLayout.razor)

I tried the following in the Routes.razor page too but it did not work:

@inject NavigationManager _NavigationManager<Router AppAssembly="@typeof(MauiProgram).Assembly"><Found Context="routeData"><RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" /><FocusOnNavigate RouteData="@routeData" Selector="h1" /></Found></Router>@code {    protected override void OnInitialized()    {        //this would have logic to set startupPage in reality        var startupPage = "/help";        _NavigationManager.NavigateTo(startupPage);    }}

So just to reiterate. I would like the @body to render as an initial page what I want depending on logic and not the @page "/" page

Thanks


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>