menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ContextMenuSettings - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ContextMenuSettings

    Represents a shortcut menu

    Inheritance
    System.Object
    ContextMenuSettings
    Namespace: Syncfusion.Blazor.Diagram
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ContextMenuSettings : OwningComponentBase
    Examples
    <SfDiagramComponent @ref="diagram" Height="600px" Width="90%" @bind-Nodes="nodes" >
    <ContextMenuSettings @bind-Show="@show" @bind-ShowCustomMenuOnly="@customMenuOnly" @bind-Items="@Items" ContextMenuOpening="@BeforeOpen" ContextMenuItemClicked="@ItemClicked">
    </ContextMenuSettings>
    </SfDiagramComponent>
    @code {
    SfDiagramComponent diagram;
    DiagramObjectCollection<Node> nodes = new DiagramObjectCollection<Node>();
    ContextMenuSettings ContextMenuSettings;
    List<ContextMenuItem> Items;
    bool customMenuOnly = false;
    bool show = true;
    protected override void OnInitialized()
    {
    
       Items = new List<ContextMenuItem>()
       {
                new ContextMenuItem()
               {
                   Text = "Save As...",
                   Id = "save",
                   IconCss = "e-save",
               },
               new ContextMenuItem()
               {
                   Text = "Group",
                   Id = "load",
                   IconCss = "e-group"
               }
       };
      Node node = new Node()
      {
        // Position of the node
        OffsetX = 250,
        OffsetY = 250,
        // Size of the node
        Width = 100,
        Height = 100,
          };
          nodes.Add(node);
    }

    Constructors

    ContextMenuSettings()

    Initializes a new instance of the ContextMenuSettings class.

    Declaration
    public ContextMenuSettings()

    Properties

    ChildContent

    Gets or sets the child content of ContextMenuSettings.

    Declaration
    public RenderFragment ChildContent { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.RenderFragment

    ContextMenuItemClicked

    Gets or sets the callback to trigger while menu items gets clicked

    Declaration
    public EventCallback<DiagramMenuClickEventArgs> ContextMenuItemClicked { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<DiagramMenuClickEventArgs>

    ContextMenuOpening

    Gets or sets the callback to trigger before opening context menu

    Declaration
    public EventCallback<DiagramMenuOpeningEventArgs> ContextMenuOpening { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<DiagramMenuOpeningEventArgs>

    ContextMenuTemplate

    Represents segment of UI rendered for the context menu items.

    Declaration
    public RenderFragment<ContextMenuItem> ContextMenuTemplate { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.RenderFragment<ContextMenuItem>
    Examples
    <SfDiagramComponent>
    <ContextMenuSettings>
    <ContextMenuTemplate>
       @context.Text
       <span class="shortcut">@((@context.Text == "Save As...") ? "Ctrl + S" : "")</span>
    </ContextMenuTemplate>
    </ContextMenuSettings>
    </SfDiagramComponent>

    Items

    Gets or sets a value indicating the collection of ContextMenuItem objects associated with the menu.

    Declaration
    public List<ContextMenuItem> Items { get; set; }
    Property Value
    Type
    System.Collections.Generic.List<ContextMenuItem>
    Examples
    <SfDiagramComponent>
    <ContextMenuSettings  @bind-Items="@Items" >
    </ContextMenuSettings>
    </SfDiagramComponent>
    @code {
    protected override void OnInitialized()
    {
    
       Items = new List<ContextMenuItem>()
       {
                new ContextMenuItem()
               {
                   Text = "Save As...",
                   Id = "save",
                   IconCss = "e-save",
               },
       };
    }

    ItemsChanged

    Specifies the callback to trigger when Items value changes

    Declaration
    public EventCallback<List<ContextMenuItem>> ItemsChanged { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<System.Collections.Generic.List<ContextMenuItem>>

    Show

    Gets or sets a value indicates whether the contextmenu is displayed.

    Declaration
    public bool Show { get; set; }
    Property Value
    Type Description
    System.Boolean

    true, the context menu can be enabled; Otherwise false.

    Remarks

    By default, the Show is set to false. The context menu can be enabled by setting the Show to true.

    Examples
    <SfDiagramComponent>
    <ContextMenuSettings @bind-Show="@show"  @bind-Items="@Items">
    </ContextMenuSettings>
    <SfDiagramComponent>
    @code {
    bool show = true;
    protected override void OnInitialized()
    {
    
       Items = new List<ContextMenuItem>()
       {
                new ContextMenuItem()
               {
                   Text = "Save As...",
                   Id = "save",
                   IconCss = "e-save",
               },
       };
    }

    ShowChanged

    Specifies the callback to trigger when show value changes

    Declaration
    public EventCallback<bool> ShowChanged { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<System.Boolean>

    ShowCustomMenuOnly

    Gets or sets the value indicates whether the custom menu items are displayed.

    Declaration
    public bool ShowCustomMenuOnly { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    By default, the ShowCustomMenuOnly is set to false. The context menu can be enabled by setting the ShowCustomMenuOnly to true.

    Examples
    <ContextMenuSettings @bind-Show="@show" @bind-ShowCustomMenuOnly="@customMenuOnly" >
    </ContextMenuSettings>
    @code {
    bool customMenuOnly = false;
    bool show = true;
    protected override void OnInitialized()
    {
    
    }

    ShowCustomMenuOnlyChanged

    Specifies the callback to trigger when ShowCustomMenuOnly value changes

    Declaration
    public EventCallback<bool> ShowCustomMenuOnlyChanged { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<System.Boolean>

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    Dispose()

    This method releases all unmanaged resources.

    Declaration
    public void Dispose()

    OnAfterRenderAsync(Boolean)

    Method invoked after each time the component has been rendered.

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender

    Set to true for the first time component rendering, otherwise gets false.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    OnInitializedAsync()

    This method is invoked when the component is ready to start.

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    OnParametersSetAsync()

    Method invoked when any changes in component state occur.

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    ="Task".

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved