Class RadzenContextMenu
RadzenContextMenu component.
public class RadzenContextMenu : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IAsyncDisposable
- Inheritance
-
RadzenContextMenu
- Implements
- Inherited Members
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()
public RadzenContextMenu()
Properties
Reference
Gets the reference for the current component.
protected DotNetObjectReference<RadzenContextMenu> Reference { get; }
Property Value
- DotNetObjectReference<RadzenContextMenu>
The reference.
UniqueID
Gets or sets the unique identifier.
public string UniqueID { get; set; }
Property Value
- string
The unique identifier.
Methods
BuildRenderTree(RenderTreeBuilder)
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builder
RenderTreeBuilder
Close()
Closes this instance.
public Task Close()
Returns
CloseMenu()
Closes this instance.
[JSInvokable("RadzenContextMenu.CloseMenu")]
public void CloseMenu()
DisposeAsync()
public ValueTask DisposeAsync()
Returns
OnAfterRenderAsync(bool)
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
firstRender
bool
Returns
OnInitialized()
protected override void OnInitialized()
Open(MouseEventArgs, ContextMenuOptions)
Opens the menu.
public Task Open(MouseEventArgs args, ContextMenuOptions options)
Parameters
args
MouseEventArgsThe MouseEventArgs instance containing the event data.
options
ContextMenuOptionsThe options.