Expand Parent-Menu in Sidebar

Hello everyone,

Is there a way to automatically have the parent menu of the sidebar expanded?

This is my Razor code:

<RadzenSidebar Style="position: relative;" @bind-Expanded="@SidebarExpanded">
	<RadzenPanelMenu DisplayStyle="@(SidebarExpanded ? MenuItemDisplayStyle.IconAndText : MenuItemDisplayStyle.Icon)" ShowArrow="true">
		<RadzenPanelMenuItem Path="/Profile" Text="My Profile" Icon="person" class="profile-sidebar-item"/>
		<RadzenPanelMenuItem Text="Subordinates" Icon="supervisor_account" class="profile-sidebar-item">
		@foreach (var subordinate in _subordinates)
		{
			var nameParts = subordinate.FullName.Split(' ');
			var firstNameLastNameWithSpace = nameParts.Last() + " " + nameParts.First();
			var path = "/subordinate/" + subordinate.EntraId;
			<RadzenPanelMenuItem Path="@path" Text="@firstNameLastNameWithSpace" class="subordinate-navigation-item"/>
		}
		</RadzenPanelMenuItem>
	</RadzenPanelMenu>
</RadzenSidebar>

(The SidebarExpanded variable is the same as in the Radzen Blazor example code so that the sidebar is expanded.)

My goal is that when I open the /Profile URL, the Subordinate menu is expanded from the beginning, like this:

and not like this:

I hope, I explained it good enough :sweat_smile:

Have you tried setting the Expanded property of the corresponding item?

<RadzenPanelMenuItem Text="Subordinates" Icon="supervisor_account" class="profile-sidebar-item" 
  @bind-Expanded="@shouldExpandSubordinates">
1 Like

Thanks, following code worked perfect for me:

<RadzenPanelMenuItem 
    Text="Subordinates" 
    Icon="supervisor_account" 
    class="profile-sidebar-item" 
    @bind-Expanded="@_shouldExpandSubordinates ">

@code {
    private bool _shouldExpandSubordinates = true;
}