Articles in this section
Category / Section

How to restrict the symbol dropping from the SymbolPalette in the WPF Diagram (SfDiagram)?

3 mins read

The symbols can be restricted from the symbol palate before dropping on the diagram page by using the Cancel argument of the ItemDropEventArgs class and ItemDropEvent of WPF Diagram (SfDiagram) class.

C#

public partial class MainWindow : Window
{
  public MainWindow()
  {
    InitializeComponent();
    SfDiagram diagram = new SfDiagram();
    (diagram.Info as IGraphInfo).ItemDropEvent += MainWindow_ItemDropEvent;
  }
 
  private void MainWindow_ItemDropEvent(object sender, ItemDropEventArgs args)
  {
    if (args.ItemSource == Cause.Stencil && (args.Source as INode).Key.ToString() == "Basic Shapes")
    {
      args.Cancel = true;
    }
  }
}

 

A close up of text on a white background

Description automatically generated

View sample in GitHub.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied