Class DiagramMenuOpeningEventArgs
Represents event arguments for the SfDiagramComponent context menu opening event.
Inheritance
Namespace: Syncfusion.Blazor.Diagram
Assembly: Syncfusion.Blazor.dll
Syntax
public class DiagramMenuOpeningEventArgs : Object
Remarks
This class provides data for the context menu opening event, allowing customization of menu items before the context menu is displayed to the user.
Examples
<SfDiagramComponent @ref="diagram" Height="600px" Width="90%">
<ContextMenuSettings @bind-Show="@show"
@bind-ShowCustomMenuOnly="customMenuOnly"
@bind-Items="@Items"
ContextMenuOpening="@BeforeOpen"
ContextMenuItemClicked="@ItemClicked">
</ContextMenuSettings>
</SfDiagramComponent>
@code {
SfDiagramComponent diagram;
ContextMenuSettings ContextMenuSettings;
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 = "glyphicon glyphicon-pencil",
},
new ContextMenuItem()
{
Text = "Group",
Id = "load",
//IconCss = "e-save"
}
};
}
private void BeforeOpen(DiagramBeforeMenuOpenEventArgs args)
{
foreach (ContextMenuItem Item in args.Items)
{
if (Item.Text == "Groups")
{
args.HiddenItems.Add(Item.Id);
}
}
}
private void ItemClicked(DiagramMenuEventArgs args)
{
if (args.Item.Text == "Group")
{
diagram.SelectAll();
diagram.Group();
}
}
Constructors
DiagramMenuOpeningEventArgs()
Declaration
public DiagramMenuOpeningEventArgs()
Properties
Cancel
Gets or sets a value indicating whether the context menu opening can be prevented.
Declaration
public bool Cancel { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | A System.Boolean indicating whether to cancel the menu opening operation. The default value is false. |
Remarks
Set this property to true to prevent the context menu from being displayed to the user.
HiddenItems
Gets or sets the collection of hidden items associated with the context menu.
Declaration
public List<string> HiddenItems { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<System.String> | A System.Collections.Generic.List<> of System.String containing the identifiers of menu items to be hidden. The default value is null. |
Remarks
Use this property to specify which menu items should not be displayed in the context menu by providing their string identifiers.
Items
Gets or sets the collection of menu items available in the context menu.
Declaration
public List<ContextMenuItem> Items { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<ContextMenuItem> | A System.Collections.Generic.List<> of ContextMenuItem representing the available menu items. The default value is null. |
Remarks
This property provides access to the collection of context menu items that can be customized or modified before the menu is displayed.