in our existing applications we are using the GoDiagram Control, but now we evaluating a WPF Diagram Control for new applications.
To my question:
in my application, a diagram contains predefined blocks that are need to be filled by the user with blocks from the toolbox.
The blocks are templates/placeholders which are need to be filled with blocks (with different software functionalities) from the toolbox.
If elements from the toolbox are now dragged onto the diagram, the blocks should snap into the placeholders when they are near and then disengage again when the mouse moves away.
Is it possible to do that with GoXam diagram? If yes, how :-) ?
Yes, take a look at the Planogram sample. The “Allowed” areas correspond to “Racks” in the Planogram sample, which are implemented with Groups.
It isn’t clear from your problem description, but is the red “Restricted Area” supposed to be the diagram background where the user may not drop objects? If so, you can implement that in the same way that the Flowgrammer sample prevents the user from dropping in the background, but only on Nodes or Links. Implement a custom DraggingTool and override (at least) the DropOnto method to call DoCancel when you don’t want a drop to do anything.
As you can see in the Flowgrammer’s CustomDraggingTool.DropOnto method, it looks for any Parts at the drop point. If there are none, it calls DoCancel. Otherwise it clears any feedback that it may have provided in the override of DragOver.