Class RadzenContextMenu
RadzenContextMenu component.
Inheritance
System.Object
RadzenContextMenu
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenContextMenu : IAsyncDisposable
Examples
@inject ContextMenuService ContextMenuService
<RadzenButton Text="Show context menu" ContextMenu=@(args => ShowContextMenuWithItems(args)) />
@code {
void ShowContextMenuWithItems(MouseEventArgs args)
{
ContextMenuService.Open(args,
new List<ContextMenuItem> {
new ContextMenuItem() { Text = "Context menu item 1", Value = 1 },
new ContextMenuItem() { Text = "Context menu item 2", Value = 2 },
new ContextMenuItem() { Text = "Context menu item 3", Value = 3 },
}, OnMenuItemClick);
}
void OnMenuItemClick(MenuItemEventArgs args)
{
Console.WriteLine($"Menu item with Value={args.Value} clicked");
}
}
Properties
Reference
Gets the reference for the current component.
Declaration
protected DotNetObjectReference<RadzenContextMenu> Reference { get; }
Property Value
Type | Description |
---|---|
DotNetObjectReference<RadzenContextMenu> | The reference. |
UniqueID
Gets or sets the unique identifier.
Declaration
public string UniqueID { get; set; }
Property Value
Type | Description |
---|---|
System.String | The unique identifier. |
Methods
Close()
Closes this instance.
Declaration
public async Task Close()
Returns
Type | Description |
---|---|
Task |
CloseMenu()
Closes this instance.
Declaration
public void CloseMenu()
DisposeAsync()
Declaration
public async ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
OnAfterRenderAsync(Boolean)
Declaration
protected override async Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type | Description |
---|---|
Task |
OnInitialized()
Declaration
protected override void OnInitialized()
Open(MouseEventArgs, ContextMenuOptions)
Opens the menu.
Declaration
public async Task Open(MouseEventArgs args, ContextMenuOptions options)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | args | The |
ContextMenuOptions | options | The options. |
Returns
Type | Description |
---|---|
Task |