Drag from Pallete

Could you please advise …

What I’m trying to achive is to add an adorment to a Group when it’s being dragged over.

I got the process working - but it only seemed to work for nodes dragged within the Diagram canvas - and not for items dragged from the Pallete.

When an item is dragged from the pallete - it seems to use the Pallete’s DragTool until it drags over the Diagram canvas, at which point it starts using the DragTool from the Canvas.

The problem I am getting is that, when it transitions to the diagrams drag tool - it does not DoActivate it.

To work around the problem - I have added some additional logic to activate the Drag tool if it’s not already active. Combined with a few other tweaks, this seems to work, but I’m not sure if there is an out-of-the-box method to do this process.

In addition to this, when an item is dropped onto a Group - I allocate an unique index number to the Node’s Data but at some point the data is lost. It looks like it’s something todo with the Temporary node that has been created. At what point in the Drag drop process can I set data on the node and have it persisted ?

My first reaction is to ask whether adding an Adornment to the stationary (dragged-over) Group is required. The point of the Part.IsDropOntoAccepted dependency property is to permit such customizations of appearance totally within XAML.

Are you using Silverlight or WPF? The drag-and-drop behaviors between controls is different.

You could override DraggingTool.DropOnto to do the modifications you are interested in.
The DraggingTool removes the temporary copies, adds the permanent copies, moves them appropriately, and then calls DropOnto.

I am using silverlight - and have just oday moved to using the Beta 1.3 version.
Ah, I should not have called it an adornment - I’ve replicated the functionality that you have used in the LinkingTool - ie. when a link is dragged over a linkable spot - then the tool draws a box around the spot. This part of my code works well - when I drag over a group node, a DataTemplate is drawn in-front of the group.

It’s possiblity something that I’m doing wrong, but I don’t seem to get any DropOnto calls when an Node is dragged from the Pallete. I am getting the DragOver calls however.

That’s very odd – if you are getting calls to DraggingTool.DragOver during a drag from the Palette to a Diagram, you ought to be getting a call to DraggingTool.DropOnto upon a drop in that Diagram.

In looking at the code, I don’t see how that could be.
Unless maybe your DraggingTool is being stopped (canceled?) or maybe there’s a mouse-down happening before the drop happens?

Is the drop happening OK otherwise – i.e. a copy of the selection being added to the diagram and moved to where the mouse is?

Sorted. Again, me trying to be too clever.

I hacked my code right back to basics, and then restarted it!

Is there any mechanism to ensure that a dragged part(s) is always on-top? Should I be changing the Layer for all the dragged parts?

Define this resource:
<go:BooleanStringConverter x:Key=“theBooleanLayerConverter” TrueString=“Foreground” FalseString="" />

And then add this data-binding to your DataTemplate(s):
go:Part.LayerName="{Binding Path=Part.IsSelected, Converter={StaticResource theBooleanLayerConverter}}"

Sorted thanks.