Home » Drag and Drop Manager | CodePlex | Silverlight

Silverlight Drag and Drop Manager released @ CodePlex

26. February 2009 by Kevin Dockx 5 Comments

A few weeks ago, I started thinking about designing custom controls for Silverlight, controls I could re-use in various projects.  Instead of just playing around, I figured I might as well make something I could put to use.  Seeing I didn’t find a true, free drag ‘n drop control, I decided to make one myself.

That little project evolved into a drag and drop manager for Silverlight.  There’s still room for improvement, but I’m quite happy with where the project is at at the moment.  And because other people might be able to use a control like this, I decided to make a Codeplex project, so everyone can get this control for free, including sourcecode! :-) 

For those of you who don’t want to read the rest, here’s the link to Drag and Drop Manager @ Codeplex.  And of course, an online sample!

 

The Silverlight Drag And Drop Manager consists of 2 controls (and their corresponding event argument classes): *DragSource* & *DropTarget*.  The first one makes any control draggable: just add the control (and if you wish, a ghost for that control) as the Content-property of the DragSource. 

The DropTarget defines a place in your application where you can drop your DragSources.  Every DragSource has a list of DropTargets on which it can be dropped, thus defining the possible DropTargets for a DragSource.  On the other hand, every DropTarget has a Content-property, which can contain anything that's a DragSource (assuming the correct rights).

Typically, you'd create a list of DropTargets & a list of DragSources on screen if you want to be able to drag those DragSources into your DropTargets.  If you want to have two lists, and want to be able to drag the DragSources back to their original position, you 'd create a list of empty DropTargets, and a list of DropTargets with DragSources as their Content.

Both controls can be added to your Silverlight-app using CodeBehind or using XAML notation.  They both expose different events you can bind handlers to, if needed, eg: DragSourceDropped-event, DropTargetEntered event, et cetera.

Next to that, both controls are *highly configurable*, so lots of possible scenarios are available.  Have a look at the sample application to see a few of them in action! 

 

Full sourcecode, documentation, online sample & binary: Drag and Drop Manager.

Comments are welcome, discussions, feature requests, bug reports, …  can be reported @ Codeplex.

Enjoy! :-)

 

 

Comments (5) -

 

Nathan Brouwer said:

It doesnt seem to work? Tried in FireFox and IE...

 

Kevin Dockx said:

Hello Nathan, is the Silverlight-plugin installed correctly?  I tried it in IE, Firefox & Chrome, and it works correctly.  Do you get some kind of error message?

 

Katrien said:

Nice work Kevin!

 

Appleman said:

Great solution.  I am wondering if there is anyway to have the dragsources resize to fill the droptarget.  For example, I have multiple drag sources that are all different sizes.  I want the content inside the drag sources to resize when the window is resized.  so the drag sources are in a grid with column widths set to "*".  The problem I see is that the drag source is surrounded by a Canvas that we need to find the position of the drag source.  Any ideas?

 

Dmitry.Portnov said:

hello, Kevin!
It's great work!
I have a question, how can i change size of dragsource control?

as for droptarget, i can make this simply steps
droptarget1.Width = 50;
droptarget1.Height= 30;
but when i do the same for dragsource, it's not working, can you help me?

Comments are closed