ListBox Item Drag & Drop

May 20, 2009 at 7:28 AM

Hello.  I was wondering if anyone has a working demo of dragging and dropping individual items between two ListBox controls using the Drag Drop Manager.  I'm new to Silverlight and have learned a lot from the Drag Drop Manager source code but I've tried to no avail to implement D&D for single listbox items (as opposed to the whole control).

Any help would be much appreciated.



May 20, 2009 at 11:30 AM



I haven't got a running sample of drag/dropping between different listbox items, but I'll try and make one for the next release.  But: if you get the latest source code (source code tab), you've got everything you need.  You might want to check this post for reference: 

In short:

- in the listbox' template, put a droptarget with in it a dragsource

- use the "AnyDropTargetValid"-property on your dragsources

- handle the "dragsourcedropped"-event on your droptarget to add/remove the item from the underlying observablecollection of your listboxes



May 26, 2009 at 9:39 AM

Hi Kev,

    Firsly thanks for sharing this great project. It will be excellent if you could give more specific explanation about integration of Drag Drop manager into Controls like ListBox, DataGrid, ComboBox and etc..

Thank you

May 29, 2009 at 11:18 AM

That's indeed a good idea - I was already thinking about extending my example app to include some typical scenarios like dragging inside a listbox etc; I'll try to find some time to do that for the next release ;-)

Jul 17, 2009 at 10:10 PM

KevD, thanks for you project.

I added a droptarget on a listbox's datatemplate, but it doesn't allow direct content. So i can't add any children to it.


Jul 20, 2009 at 1:48 PM

Hello jocknuke,


DropTargets can only contain DragSources (allowing other content wouldn't really make sense: only draggable controls should be added to a droptarget, otherwise, there's no use in using a droptarget :-)).  So, if you want content in your droptarget, you can add a dragsource in your template as well.