Resizing of DropTargets

Nov 7, 2011 at 12:12 PM
Edited Nov 7, 2011 at 12:13 PM

Hi I have a SL app that has 3 columns available for items to be added/removed/moved etc. The drag drop manager is proving invaluable in the creation of this however I have a slight issue.

The problem I'm having is that if I have for example 3 items in a single column. When I drag the top item, the droptarget zone autoresizes to its default height meaning the two items below shift upwards and get obscured from view. This behaviour can be seen in the first three Custom Behaviour demos available.

Is there anyway to set the droptargets to only update the height once an item has been dropped rather than as soon as an item is dragged?


Many Thanks


Nov 7, 2011 at 5:13 PM
Edited Nov 7, 2011 at 5:14 PM

I actually fixed this issue by using a temporary drag source that takes on the height of the item currently being dragged.



private DropTarget TempDropTarget = new DropTarget()
            Ghost = new DropTargetGhost(),
            Width = System.Double.NaN,
            Height = System.Double.NaN,
            HorizontalAlignment = HorizontalAlignment.Stretch,
            HorizontalContentAlignment = HorizontalAlignment.Stretch,
            VerticalAlignment = VerticalAlignment.Top,
            VerticalContentAlignment = VerticalAlignment.Stretch,
            Margin = new Thickness() { Bottom = 7, Left = 0, Right = 0, Top = 7 },
            ContentisMaximised = false,


This temporary target gets added on mouse click in the DragBar_MouseLeftButtonDown method:


TempDropTarget.Height = (this.OriginalParent.ActualHeight) - 14;              

And removed on mouse up (DragBar_MouseLeftButtonUp):


Hope this helps anyone else wanting this behaviour.