I'm trying to use the "Icon Sidebar" in a new Blazor Web App project in .NET 8. I have followed the installation instructions carefully and I have also tried the component in a test project which is only a Blazor server project. There I put both:
<HeadOutlet @rendermode="InteractiveServer"/>
and
<Routes @rendermode="InteractiveServer"/>
and it worked fine.
In my Blazor Web App project I don't want to set my full application to this InteractiveServer. How do I get only the "Icon Sidebar" to work as a InteractiveServer so it opens and closes when I press the burger icon?
Here is my code now:
@inherits LayoutComponentBase
<RadzenLayout>
<RadzenHeader>
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="0">
<RadzenSidebarToggle Click="@(() => sidebarExpanded = !sidebarExpanded)" />
<RadzenLabel Text="Header" />
</RadzenStack>
</RadzenHeader>
<RadzenSidebar Responsive="false" Style="width: max-content">
<RadzenPanelMenu DisplayStyle="@(sidebarExpanded ? MenuItemDisplayStyle.IconAndText : MenuItemDisplayStyle.Icon)" ShowArrow="false">
<RadzenPanelMenuItem Text="Overview" Icon="home" />
<RadzenPanelMenuItem Text="Dashboard" Icon="dashboard" />
<RadzenPanelMenuItem Text="UI Fundamentals" Icon="auto_awesome">
<RadzenPanelMenuItem Text="Themes" Icon="color_lens" />
<RadzenPanelMenuItem Text="Colors" Icon="invert_colors" />
</RadzenPanelMenuItem>
</RadzenPanelMenu>
</RadzenSidebar>
<RadzenBody>
<div class="rz-p-4">
@Body
</div>
</RadzenBody>
</RadzenLayout>
@* RADZEN COMPONENTS START *@
@*
Important! Make sure that you do not nest
<RadzenContextMenu />, <RadzenDialog />, <RadzenNotification /> and <RadzenTooltip />
inside a positioned element (i.e. with position: relative, position: absolute or position: fixed).
To be safe you can add it at the end of the layout file after all other elements.
*@
<RadzenContextMenu />
<RadzenDialog />
<RadzenNotification />
<RadzenTooltip />
@* RADZEN COMPONENTS END *@
@code {
bool sidebarExpanded = true;
}
I might add that I've tried creating a wrapper component as well but I can't get that to work either.
But correct me if I'm wrong. I don't want to run into problems later in development. The same applies to the service, this code didn't seem to make a difference either:
If I comment out the code, the application still works as it should. As I wrote, you are welcome to comment if there is something I must use in order not to run into problems later in the development.
This is the same thing happened for me. I use Radzen component + Blazor template + auth identity .NET 8 and after doing some testing here and there. (Putting
<Routes @rendermode="InteractiveServer"/>
as you suggested)
I still got the same exact error when I try to use RadzenLink with Path OR Button with NavigationManager set to "Account/Login"
The page is like doing an infinite re-render.
Do you have any idea why this happened? Because I tried using only blazor template + identity without radzen, it works fine.