Hi,
I have added context menu on XAMDiagram. but I want that as I right click on any diagram that time diagram should be select and Context Menu should be shown. Right now I have added context menu for XAMDiagram so as we right click on diagram area then context menu showing. But we want to show context menu when we right click on diagram and that time diagram should be select and context should be appear.
we want to show context menu for selected diagram. Please help us for that.
Thanks
Hi Andrew,
thank you for sharing this code. what is the best way to restrict context menu so that it only shows on nodes (I would like to restrict it to show no context menu when right click other places than nodes)
Hello piyu,
Thank you for your post!
From your description, it sounds like you have applied a context menu to the XamDiagram itself, and are trying to select the nodes and connections on right click, but still show that context menu. Please let me know if this initial impression is incorrect, as the following goes off of that impression.
To achieve this requirement, I would recommend writing a pair of implicit styles in your XamDiagram.Resources section. The target types of these styles can be for DiagramNode and DiagramConnection. I would recommend having these styles do essentially the same thing, in that they use an EventSetter to hook into the PreviewMouseRightButtonDown event, and since these styles are implicit, this will take effect on every node and connection in the diagram. Then, in the event handlers for the respective PreviewMouseRightButtonDown events, you can cast the sender of the event to the corresponding object type, and set the IsSelected property of the object to true.
I have attached a sample application to demonstrate the above. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support