Class ContextMenuItem
Represents a context menu item model for the SfDiagramComponent.
Inheritance
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class ContextMenuItem : Object
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
public bool Disabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean 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
public bool Hidden { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean indicating the visibility state. true to hide the menu item; otherwise, false. The default value is false. |
IconCss
Gets or sets the CSS class for the icon to display in the context menu item.
Declaration
public string IconCss { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.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.
ID
Gets or sets the unique identifier for the context menu item.
Declaration
public string ID { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.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.
Items
Gets or sets the collection of submenu items for this context menu item.
Declaration
public List<ContextMenuItem> Items { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ContextMenuItem> | A System.Collections.Generic.List<> 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
public bool Separator { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean 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
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.String representing the text to display for the menu item. The default value is |
Url
Gets or sets the URL for the menu item that creates an anchor link for navigation.
Declaration
public string Url { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.String representing the URL to navigate to when the menu item is clicked. The default value is |