Context menu setup
This article shows the additional setup steps required to use the RadzenContextMenu component.
Service registration
The RadzenContextMenu is used via the ContextMenuService class which must be registered as a service.
- Open
Startup.cs
- Import the Radzen namespace
using Radzen;
- Register the
ContextMenuService
in theConfigureServices
method.public void ConfigureServices(IServiceCollection services) { // Other registrations services.AddScoped<ContextMenuService>(); // Other registrations }
Add to layout
You also need to add the RadzeContextMenu component to the layout used by your pages (most commonly MainLayout.razor
).
<RadzenContextMenu />
Important! Make sure that you do not nest
<RadzenContextMenu />
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.