We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Context Menu

Thread ID:

Created:

Updated:

Platform:

Replies:

126441 Oct 14,2016 08:02 PM UTC Oct 21,2016 08:54 AM UTC WPF 5
loading
Tags: Diagram
Stratos Geroulis
Asked On October 14, 2016 08:02 PM UTC

Hello,

I have not been able to find adequate explanation on how to implement a custom context menu for the nodes in my diagram only. Basically, what I'm trying to do is open a context menu only on right click on a node and not a connection etc. Also, I want to be able to remove a couple of items from the default menu and add a couple of my own. How is it recommended on going about this with the latest version of the library?

Thank you for any of your help.
Stratos

Keerthivasan Ramamoorthy [Syncfusion]
Replied On October 19, 2016 12:13 PM UTC

Hi Stratos, 
 
Requirement:” Need to Customize the ContextMenu for Nodes”. 
 
We have support to achieve your requirement and Provided a sample to represent this. Please refer to sample link as below. 
 
Sample Link:CustomContextMenu
 
 
Sample details: 
In sample, we have set the Diagram Menu as null. So the ContextMenu did not shown for Nodes and Connectors. We have customized the contextmenu for Nodes in the ItemSelectedEvent by disabling the InheritMenu Constraints for Nodes. 
 
Constraints and ContextMenu Behavior:  
Constraints are used to enable/disable certain behaviors of the SfDiagram, Node and Connector. The default value of Menu property for Node and Connector is null. So, the Default(SfDiagram) ContextMenu is shown for Nodes and Connectors. In order to Replace the ContextMenu for Nodes/Connectors, we have disable the InheritMenu Constraints and enable the Menu Constraints for Nodes/Connectors.   
  
Note:  
For more details about ContetMenu customization, please visit our online help documentation from the below link.  
  
Documentation Link:  
 
Additional Information: 
 
In Volume 4 release, we have provided a DiagramMenuOpeningEvent support for Diagram to customize the ContextMenu and MenuItem for Nodes and Connectors. 
 
 
Regards, 
Keerthivasan R. 


Stratos Geroulis
Replied On October 19, 2016 09:53 PM UTC

Thank you for your response.

I am using the classic Diagram (DiagramControl) and not SfDiagram. As I see it, the same logic does not really apply on it. Do you have a link to another example/article that achieves the same effect as the one you described for the SfDiagram?

Thanks again,
Stratos

Ranjitha Amirthalingam [Syncfusion]
Replied On October 20, 2016 01:35 PM UTC

Hi Stratos, 
 
Thanks for the update. 
 
We have achieved your requirement in Diagram Control (Classic). We have provided the sample to represent this. Please refer to the sample from the following link. 
 
Sample Link: Custom_Context_menu
 
 
We have support for enabling/disabling ContextMenu on Node and LineConnector. We have provided codesnippet to represent this. Please refer to the codesnippet as below.

 
//for enabling ContextMenu on Node 
diagramView.NodeContextMenu = new ContextMenu { Visibility = Visibility.Visible }; 
 
//for disabling ContextMenu on Node 
diagramView.NodeContextMenu = new ContextMenu { Visibility = Visibility.Collapsed }; 
 
Here, diagramView is the instance of DiagramView. 

Regards, 
Ranjitha A. 


Stratos Geroulis
Replied On October 20, 2016 08:46 PM UTC

Thank you very much, this did the trick!

Ranjitha Amirthalingam [Syncfusion]
Replied On October 21, 2016 08:54 AM UTC

Hi Stratos,   
  
Thanks for your update.  
Please let us know if you require further assistance on this.  
  
  
Regards,  
Ranjitha A.  



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;