Dragging between palette/diagram

Hi,
I’m looking at implementing functionality where I have a palette of icons and a main diagram. I want to be able to drag a copy of an icon from the palette onto the diagram (leaving the original icon on the palette).
I’ve a number of questions related to aspects of acheiving this…
a) is it possible that when I start dragging the icon in the palette, for the cursor to show the icon I’m dragging. Currently it shows the ‘Not allowed’ icon.
b) when the mouse cursor crosses over onto the diagram, the offset of the mouse pointer from the icon is different from when I started dragging it. e.g. I click on the center of an icon in the palette and drag it to the diagram. When it is over the diagram, the cursor appears to positioned in the top-left corner of the icon. I’d like the relative position of the pointer to remain the same in the palette and the diagram.


c) if I drag an icon from the diagram back onto the palette, when the cursor leaves the diagram, the dragged image is left showing at the edge of the diagram until I drop the icon.
I have a version of this application implemented in GoDiagram and have managed to achieve what I wanted there. I've examined the sample code from GoXam, and the FlowChart sample shows the same things as described above. Thanks

I’m assuming you are using GoWPF.

a) It’s showing a “not allowed” cursor there because a drop is not permitted in the Palette. I can investigate if this can be changed easily.

b) I suppose we could improve that, but the reason it chooses the center of the node is that the DataTemplate in the Diagram could be drastically different from the template used in the Palette, such that using the same offset might be a problem

But when I run the FlowChart sample, it seems to choose the center of the dragged (and later dropped) node, not the top-left corner point.

c) I’m not seeing this behavior either, at least not in the FlowChart sample. Did you set Diagram.AllowDragOut to true? Or perhaps some other differences?

For your (a) case, you can at least have it not show the “drop-not-allowed” cursor by doing:

[1] set Palette.AllowDrop=“True”
[2] have your Palette use the following dragging tool:

[code] public class PaletteDraggingTool : DraggingTool {
protected override bool MayCopyInternal(DragEventArgs e) {
return true;
}
}

myPalette.DraggingTool = new PaletteDraggingTool();[/code]
I don’t know yet about showing the selected nodes being dragged in the palette.

Hi,

Thanks for the information.
I've managed to fix my b) case (where the mouse wasn't positioned over the center of the the node when it was dragged onto the diagram.
Adding
go:Node.LocationSpot="Center"
to the 'StackPanel' element in the 'DataTemplate' element of my XAML was the solution.
For c), my Diagram element has 'AllowDragOut' set to 'true'. The FlowChart sample doesn't have this attribute set. This seems to mean that when I try and drag a node out of the diagram, it looks like it has happened, but what really happens is the bounds of the diagram extend and the node is still on the diagram. You just can't see it unless you scroll the diagram.
Thanks