Demos About Radzen
Search Results for

    Show / Hide Table of Contents

    Class ContextMenuService

    Class ContextMenuService. Contains various methods with options to open and close context menus. Should be added as scoped service in the application services and RadzenContextMenu should be added in application main layout. Implements the IDisposable

    Inheritance
    object
    ContextMenuService
    Implements
    IDisposable
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: Radzen
    Assembly: Radzen.Blazor.dll
    Syntax
    public class ContextMenuService : IDisposable
    Examples
    @inject ContextMenuService ContextMenuService
    <RadzenButton Text="Show context menu" ContextMenu=@(args => ShowContextMenuWithContent(args)) />
    @code {
        void ShowContextMenuWithContent(MouseEventArgs args) => ContextMenuService.Open(args, ds =>
          @<RadzenMenu Click="OnMenuItemClick">
            <RadzenMenuItem Text="Item1" Value="1"></RadzenMenuItem>
            <RadzenMenuItem Text="Item2" Value="2"></RadzenMenuItem>
            <RadzenMenuItem Text="More items" Value="3">
                <RadzenMenuItem Text="More sub items" Value="4">
                    <RadzenMenuItem Text="Item1" Value="5"></RadzenMenuItem>
                    <RadzenMenuItem Text="Item2" Value="6"></RadzenMenuItem>
                </RadzenMenuItem>
            </RadzenMenuItem>
          </RadzenMenu>);
    
        void OnMenuItemClick(MenuItemEventArgs args)
        {
          Console.WriteLine($"Menu item with Value={args.Value} clicked");
        }
    }

    Constructors

    ContextMenuService(NavigationManager)

    Initializes a new instance of the ContextMenuService class.

    Declaration
    public ContextMenuService(NavigationManager uriHelper)
    Parameters
    Type Name Description
    NavigationManager uriHelper

    The URI helper.

    See Also
    IDisposable

    Methods

    Close()

    Closes this instance.

    Declaration
    public void Close()
    See Also
    IDisposable

    Dispose()

    Disposes this instance.

    Declaration
    public void Dispose()
    See Also
    IDisposable

    Open(MouseEventArgs, RenderFragment<ContextMenuService>)

    Opens the specified arguments.

    Declaration
    public void Open(MouseEventArgs args, RenderFragment<ContextMenuService> childContent)
    Parameters
    Type Name Description
    MouseEventArgs args

    The MouseEventArgs instance containing the event data.

    RenderFragment<ContextMenuService> childContent

    Content of the child.

    See Also
    IDisposable

    Open(MouseEventArgs, IEnumerable<ContextMenuItem>, Action<MenuItemEventArgs>)

    Opens the specified arguments.

    Declaration
    public void Open(MouseEventArgs args, IEnumerable<ContextMenuItem> items, Action<MenuItemEventArgs> click = null)
    Parameters
    Type Name Description
    MouseEventArgs args

    The MouseEventArgs instance containing the event data.

    IEnumerable<ContextMenuItem> items

    The items.

    Action<MenuItemEventArgs> click

    The click.

    See Also
    IDisposable

    Events

    OnClose

    Raises the Close event.

    Declaration
    public event Action OnClose
    Event Type
    Type Description
    Action
    See Also
    IDisposable

    OnNavigate

    Occurs when [on navigate].

    Declaration
    public event Action OnNavigate
    Event Type
    Type Description
    Action
    See Also
    IDisposable

    OnOpen

    Occurs when [on open].

    Declaration
    public event Action<MouseEventArgs, ContextMenuOptions> OnOpen
    Event Type
    Type Description
    Action<MouseEventArgs, ContextMenuOptions>
    See Also
    IDisposable

    Implements

    IDisposable

    See Also

    IDisposable

    Introducing Radzen Blazor Studio

    Radzen Blazor Studio is a software development environment that empowers developers to design, build and deploy Blazor applications without the traditional hurdles. Write less code and get more done.

    Learn More

    Download Now
    Download Now
    In This Article
    Back to top Radzen Blazor Components, © 2018-2025 Radzen. Source Code licensed under MIT