About drag drop


I'd like to know that is there any chance to make a custom control (something like a ListView) to hold the model of Node, and make it just show the names or keys of the Nodes? I just want to prevent the appearance of the Node to be shown before it is being dragged out of the container

You don’t say if you’re concerned about drag-and-drop in a WPF application, or if it’s in a restricted XBAP application or in a Silverlight application.

In XBAP, there’s probably no permission to do a cross-control drag-and-drop. In Silverlight, there’s no official drag-and-drop at all. So for both cases we have implemented our own drag-and-drop that works within the application’s window.

Hence one solution that will work for all three environments is to use a Diagram as your drag source.

In fact, that is exactly what the Palette control is meant to do. The NodeTemplate used in the source Palette(s) can be completely different from the template you use in your target Diagram(s). So you can use a very simple template, to just show some text.

In fact, the default template just shows your data converted to a string, and it supports showing selection. So you can just fiddle with the GridLayout properties such as CellSize to customize the positioning of the nodes, if the defaults aren’t appropriate for your collections of items.

<go:Palette x:Name="myPalette" HorizontalContentAlignment="Left" VerticalContentAlignment="Top" NodeTemplate="{StaticResource MinimalNodeTemplate}" > <go:Diagram.Layout> <go:GridLayout CellSize="10 10" Alignment="Location" Sorting="Forward" /> </go:Diagram.Layout> </go:Palette>
In your initialization code you’ll need to create and assign the myPalette.Model.NodesSource in order to populate the palette with items.

Thanks! That’s really a good solution.