Treat Move behavior like copy

Hi Walter,

In my diagram I would like the ‘move’ behavior (e.g. dragging a unit to a different location) to act like the copy (when the Ctrl button is pressed) behavior, meaning that the unit and its links will stay in their present location until the drop and I will override the drop-on-to behavior and remove the unit from the previous location.

Can you please give me a general direction about which method i need to override the move/drag and copy behaviors?

Thanks in advance,


I tried something real quick that seems to work if you are using Windows drag-and-drop on WPF:

public class NotRealtimeDraggingTool : Northwoods.GoXam.Tool.DraggingTool { protected override bool MayMoveInternal(DragEventArgs e) { if ((e.AllowedEffects & DragDropEffects.Move) == 0) return false; // source must allow move if ((e.KeyStates & DragDropKeyStates.ControlKey) != 0) return false; // trying to require COPY Diagram diagram = this.Diagram; // this diagram must allow move if (diagram == null || diagram.IsReadOnly || !diagram.AllowMove) return false; return this.IsDropping; } private bool IsDropping { get; set; } public override void DoDrop(DragEventArgs e) { this.IsDropping = true; base.DoDrop(e); this.IsDropping = false; } }
But if you’re not using Windows drag-and-drop, the solution isn’t obvious at the moment.

Thanks for the quick reply.
For some reason the MayMoveInternal method is not invoked at all when I move nodes in the diagram - i've tried to override all the relevant methods but none of them seem to invoke when I move a node Unhappy (same in the FlowGrammar example)
What could be wrong in my app?
My application is in WPF, and I'm using windows drag-and-drop when the user drag-and-drop new nodes onto the diagram. Is there another place I could/should use it?

You need to set Diagram.AllowDragOut to true in order to use Windows drag-and-drop within a diagram.

Damn property… it works! Thanks a lot!