I am building a test app using Blazor .NET 8 RC1, and have pasted one of your basic layout examples into the MainLayout page.
However when I run the app, the toggle and menu items do not respond.
I know .NET 8 is not yet released and therefore still not supported, but any feedback would be greatly appreciated.
This is the code example I have used:
I have done a completely new one, following the installation instructions from your website and I have a video shows how the UI elements are not responding to the several mouse clicks I do on both the menu expand/collapse, but also on the dropdown menu and no errors are popping up anywhere.
I am really at a loss here to what can be the reason and hope you can help.
I have attached a zip file with the full project.
After spending some more time here is what I found:
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.
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 -->
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:
This seems to enable the old pre-.NET8 behavior. Also you don't need to change anything in MainLayout.razor - it can stay the same as in .NET7. Of course by doing this you would be losing static rendering mode altogether.
Bonus - here is the explanation of this behavior by the Blazor creator himself.
Just to be clear, because these render modes have me in loops...
If I were to add this:
<Routes @rendermode="@RenderMode.Server" />
It would make all of my components / pages whatever use the Server render mode?
But if I were to make a component for the sidebar, mark that with @attribute [RenderModeServer] and leave the Routes component alone, that would allow me to use different render modes on a component to component basis?