Sidebar not working in .NET 8 RC1 experiment

After spending some more time here is what I found:

  1. This static mode is the default for all Blazor components. This means that events will not fire unless you have @attribute [RenderModeInteractiveServer] or @attribute [RenderModeInteractiveWebAssembly] or even @attribute [RenderModeInteractiveAuto]. No compilation errors or exceptions - it just won't work silently. We can't fix that in any way - this is how .NET 8 Blazor is for now.
  2. You can't easily use @attribute [RenderModeInteractiveServer] or the similar in MainLayout. It will break when you use @Body.

I found a workaround (and also hit another issue).
It is to put the Sidebar and Header in a separate component which has the much needed @attribute [RenderModeServer] and use it in the layout. Find attached a working project.

<RadzenNotification @rendermode="@RenderMode.InteractiveServer" />

<RadzenLayout style="height: 400px">
    <Navigation /> <!-- This contains the interactive sidebar and toggle -->
    <RadzenBody>
        <div class="rz-p-4">
            @Body
        </div>
    </RadzenBody>
    <RadzenFooter>
        Footer
    </RadzenFooter>
</RadzenLayout>

Also note the @rendermode setting of RadzenNotification - it is needed otherwise it won't work

By the way your app was missing two critical things in Program.cs which are required for any interactivity:

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents(); // <--

and

app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode(); // <--

I have added them in the attached app.
Radzen.Net8.zip (155.4 KB)

1 Like