Class ContextMenuItem
Represents the context menu item model.
Inheritance
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class ContextMenuItem : Object
Remarks
The custom context menu provides an option to add the 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>
ContextMenuSettings ContextMenuSettings;
//@code{
List<ContextMenuItem> Items;
bool customMenuOnly = false;
bool show = true;
protected override void OnInitialized()
{
nodes = new DiagramObjectCollection<Node>();
connectors = new DiagramObjectCollection<Connector>();
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()
Declaration
public ContextMenuItem()
Properties
Disabled
Gets or sets a value indicates whether allows the users to enable/disable the menu item.
Declaration
public bool Disabled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true, the contextmenu item is not in enable state. Otherwise, false. The default value is false |
Hidden
Gets or sets a value indicates whether allows the users to show/hide the menu item.
Declaration
public bool Hidden { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true, the contextmenu item is not in visible state. Otherwise, false. The default value is false |
IconCss
Gets or sets a value indicates css class for icon to the context menu item.
Declaration
public string IconCss { get; set; }
Property Value
Type |
---|
System.String |
Remarks
The IconCss property defines the class/multiple classes separated by a space for the menu item that is used to include an icon. A menu item can include a font icon and sprite image.
ID
Gets or sets the ID for the context menu item.
Declaration
public string ID { get; set; }
Property Value
Type |
---|
System.String |
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 a value indicates the submenu items.
Declaration
public List<ContextMenuItem> Items { get; set; }
Property Value
Type |
---|
System.Collections.Generic.List<ContextMenuItem> |
Separator
Gets or sets a value indicates the horizontal line used to separate the menu items. Users can enable or disable the separator to group the menu item.
Declaration
public bool Separator { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true, the separator will be added between the menuitems. Otherwise, false. The default value is false |
Text
Gets or sets a value indicates the text for a context menu item.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | By default the text value is empty. |
Url
Gets or sets the URL for the menu item that creates the anchor link to navigate to the URL provided.
Declaration
public string Url { get; set; }
Property Value
Type | Description |
---|---|
System.String | By default the url value is empty. |