Class RadzenContextMenu
RadzenContextMenu component.
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenContextMenu : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, 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");
}
}
Constructors
RadzenContextMenu()
RadzenContextMenu component.
Declaration
public RadzenContextMenu()
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 |
---|---|
string | The unique identifier. |
Methods
BuildRenderTree(RenderTreeBuilder)
RadzenContextMenu component.
Declaration
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
Type | Name | Description |
---|---|---|
RenderTreeBuilder | __builder |
Overrides
Close()
Closes this instance.
Declaration
public Task Close()
Returns
Type | Description |
---|---|
Task |
CloseMenu()
Closes this instance.
Declaration
[JSInvokable("RadzenContextMenu.CloseMenu")]
public void CloseMenu()
DisposeAsync()
RadzenContextMenu component.
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
OnAfterRenderAsync(bool)
RadzenContextMenu component.
Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
bool | firstRender |
Returns
Type | Description |
---|---|
Task |
Overrides
OnInitialized()
RadzenContextMenu component.
Declaration
protected override void OnInitialized()
Overrides
Open(MouseEventArgs, ContextMenuOptions)
Opens the menu.
Declaration
public Task Open(MouseEventArgs args, ContextMenuOptions options)
Parameters
Type | Name | Description |
---|---|---|
MouseEventArgs | args | The MouseEventArgs instance containing the event data. |
ContextMenuOptions | options | The options. |
Returns
Type | Description |
---|---|
Task |