Replies: 1 comment
-
Surprisingly, for some reason, wrapping everything inside a SectionContent helps! <SectionOutlet SectionName="Test" />
<SectionContent SectionName="Test">
<CascadingValue Value="layoutModel">
<PageTitle>@(layoutModel.Title ?? "NO TITLE")</PageTitle>
<PageHeader />
<div>
Title: @(layoutModel.Title)
@(layoutModel.Wide)
</div>
</CascadingValue>
</SectionContent> The content is up-to-date with the value set by the Component! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Similar to this question on SO: https://stackoverflow.com/questions/79677250/pass-parameters-from-a-component-to-a-layout-in-blazor-web-app-with-server-sta
I'm using .NET 8 Blazor Web App with static rendering. In MVC/Razor Pages, a page could pass variables (such as a bool) to the layout using ViewBag or similar mechanics, allowing the layout to conditionally show or hide parts of the UI, or in my case, add a class name to the tag.
In Blazor, I tried to implement something similar to HeadContent/HeadOutlet by using: a shared service, Cascading Parameters; I even have an event and call StateHasChanged when the property is set but it's not reflected in the layout.
There is one exception: if a HeadOutlet access that shared variable, the content is up-to-date.
How does HeadOutlet do that? Can I somehow change the content of Layout from a Component and notify SSR to match?
Beta Was this translation helpful? Give feedback.
All reactions