alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class ContextMenuItem

    Represents a context menu item model for the SfDiagramComponent.

    Inheritance
    object
    ContextMenuItem
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Syncfusion.Blazor.Diagram
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ContextMenuItem
    Remarks

    The custom context menu provides an option to add new custom items to the context menu. Those additional custom items have to be defined and added to the Items property of the context menu.

    Examples
    <SfDiagramComponent @ref="diagram" Height="600px" Width="90%">
        <ContextMenuSettings @bind-Show="@show"
                           @bind-ShowCustomMenuOnly="customMenuOnly" 
                           @bind-Items="@Items">
            <ContextMenuTemplate>
                @context.Text
                <span class="shortcut">@((@context.Text == "Save As...") ? "Ctrl + S" : "")</span>
            </ContextMenuTemplate>
        </ContextMenuSettings>
    </SfDiagramComponent>
    @code{
        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"
                }
            };
        }
    }

    Constructors

    ContextMenuItem()

    Initializes a new instance of the ContextMenuItem class.

    Declaration
    public ContextMenuItem()

    Properties

    Disabled

    Gets or sets a value indicating whether the menu item is disabled.

    Declaration
    [JsonPropertyName("disabled")]
    public bool Disabled { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating the enabled state. true to disable the menu item; otherwise, false. The default value is false.

    Hidden

    Gets or sets a value indicating whether the menu item is hidden from view.

    Declaration
    [JsonPropertyName("hidden")]
    public bool Hidden { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating the visibility state. true to hide the menu item; otherwise, false. The default value is false.

    ID

    Gets or sets the unique identifier for the context menu item.

    Declaration
    [JsonPropertyName("id")]
    public string ID { get; set; }
    Property Value
    Type Description
    string

    A string representing the unique ID for the menu item. The default value is a randomly generated ID.

    Remarks

    Menu item ID needs to be unique to use. When creating a menu item, the user should not provide the same id to other menu items.

    IconCss

    Gets or sets the CSS class for the icon to display in the context menu item.

    Declaration
    [JsonPropertyName("iconCss")]
    public string? IconCss { get; set; }
    Property Value
    Type Description
    string

    A string representing the CSS class or multiple classes separated by spaces for the menu item icon. The default value is null.

    Remarks

    The IconCss property defines the class/multiple classes separated by a space for the menu item that is used to include an icon.

    Items

    Gets or sets the collection of submenu items for this context menu item.

    Declaration
    [JsonPropertyName("items")]
    public List<ContextMenuItem?>? Items { get; set; }
    Property Value
    Type Description
    List<ContextMenuItem>

    A List<T> of ContextMenuItem objects representing the submenu items. The default value is null.

    Remarks

    Use this property to create hierarchical menu structures with nested menu items.

    Separator

    Gets or sets a value indicating whether a separator line should be displayed after this menu item.

    Declaration
    [JsonPropertyName("separator")]
    public bool Separator { get; set; }
    Property Value
    Type Description
    bool

    A bool indicating whether to show a separator line. true to display the separator; otherwise, false. The default value is false.

    Remarks

    The horizontal line is used to separate the menu items. Users can enable or disable the separator to group the menu items.

    Text

    Gets or sets the display text for the context menu item.

    Declaration
    [JsonPropertyName("text")]
    public string Text { get; set; }
    Property Value
    Type Description
    string

    A string representing the text to display for the menu item. The default value is string.Empty.

    Url

    Gets or sets the URL for the menu item that creates an anchor link for navigation.

    Declaration
    [JsonPropertyName("url")]
    public string Url { get; set; }
    Property Value
    Type Description
    string

    A string representing the URL to navigate to when the menu item is clicked. The default value is string.Empty.

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