I am trying to find out the events fired by xamDiagram when an item from toolbox is being dragged and moved around within diagram.
Take a look at this attached screenshot of one of the samples included in controls, I am trying to drag (& drop) rectangle onto diagram, how can I detect an item being dragged on it?
Hello Abs,
There is no specific event triggered when an item from the toolbox is being dragged and moved within the xamDiagram control. The events for the toolbox item dragging from the toolbox are handled internally and there are no publicly exposed events.
Several events are triggered when the item is already dropped within the xamDiagram surface. These are the XamDiagram ItemAdding, ItemAdded, NodeMoving and NodeMoved events.
If this is an option for you, you can handle the PreviewMouseDown and PreviewMouseUp events to handle when a toolbox item is clicked and when the mouse button is released for the DiagramToolboxCategoryItem.
I’ve attached a sample project demonstrating this.
We need to take some actions when an item is being dragged on the diagram, but not dropped yet. We programmatically add the new item to the model and the connections are also added automatically.
What we want to do is to highlight the potential existing items the dragged item can be connected with. This is why we need to know when something is being dragged (as well as its current location).
We understand you do not expose these events right now but do you plan to do this in a future version? Also, the diagram exposes the MouseMove event, inherited from WPF. This is being fired but oddly, not when an item is dragged from the diagram. That is, we can intercept this event if the mouse is moved across the diagram, but not when the mouse drags an item across the diagram. Is this the intended behavior?
XamDiagram MouseMove occurs when the mouse pointer moves over the xamDiagram. I guess that in your scenario, you may need to handle the XamDiagramToolbox MouseMove event if you drag a diagram item from the diagram toolbox. Once the item is dropped, you can use the xamDiagram NodeMoving/NodeMoved events.
I have attached a modified sample.
Also, you can suggest your new product idea for future versions (or vote for existing ones) at <http://ideas.infragistics.com>.
Submitting your idea will allow you to communicate directly with our product management team, track the progress of your idea at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. You can also link back to this thread for additional details.
Thank you in advance to submitting your product idea.
Thank you for your suggestion and the sample, we have tried that and confirmed that we can use the toolbox’s mouse move event. However, this event does not tell us what item is dragged. The ItemAdding event, for example, has an Item property in the DiagramItemAddingEventArgs. How can we determine what is being dragged?
One option to define which is the dragged toolbox item is to handle the DiagramToolboxCategoryItem PreviewMouseDown event. If the toolbox item is one of the predefined items – its ShapeType can be taken into account. If the toolbox item is custom, you can set its Tag property and use it as identifier.
Have in mind that when you drop the toolbox item on the xamDiagram surface - a new diagram item is created and the Tag property won’t be relevant anymore.
I’ve attached a sample to demonstrate this using a custom created toolbox items.
Let me know if you have any questions.