I have a Sidebar which includes menu items which is defined like this:
<SfSidebar HtmlAttributes="@HtmlAttribute" Target=".main-content" Width="220px" DockSize="50px" EnableDock="true" Type=SidebarType.Push @ref="sideBar">
<ChildContent>
<div class="main-menu">
<p class="main-menu-header">ICE-T</p>
<div>
<SfMenu CssClass="dock-menu" Items="@MainMenuItems" Orientation="@VerOrientation" @ref="MainMenu"><MenuEvents ItemSelected="onMenuSelect"></MenuEvents></SfMenu>
</div>
</div>
</ChildContent>
</SfSidebar>
Included in @MainMenuItems is a MenuItem defined like this:
new MenuItem {
Id="Line",
Text = "Dial",
IconCss = "oi-grid-three-up",
Items = new List<MenuItem> {
new MenuItem{ Text = "Dial pad ..." },
new MenuItem{ Separator=true},
new MenuItem{ Text = "Provisioning" },
new MenuItem{ Text = "Accounts" },
new MenuItem{ Text = "Network Services" },
new MenuItem{ Text = "IT Help Desk" },
new MenuItem{ Text = "Customer Subscriptions Team" }
}
},
In response to user actions within my project I need to update the MenuItem with ID = "Line" and change its IconCss property from "oi-grid-three-up" to "oi_bell".
To do that in the code for the Index.razor page which hosts the Sidebar I do this:
MenuItem lineButton = MainMenuItems.Find(item => item.Id == "Line");
lineButton.IconCss = "oi-bell";
this.MainMenu.SetItem(lineButton);
However, the icon is not updated and there is a "Component parameter 'IconCss' should not be set outside of its component" compiler warning against the lineButton.IconCss = "oi-bell" statement.
Obviously I'm doing something wrong What's the correct way to update the MenuItem.IconCss property?