Welcome to MSDN Blogs Sign in | Join | Help

Lester's WPF blog


Simple, easy & beautiful
Drag drop library

Some time back Marcelo had written a series of posts covering drag and drop. This was interesting reading and I had uploaded the C# code in one of my previous posts. Recently, I came across Pavans blog where he shows the same using attached properties. The code is written with reusability and ease of use in mind.

To use the code you would need to specify the source and the destination (putting it in layman terms)

<local:CanvasDragDropAdvisor x:Key="advisor"/>

<Canvas Background="White" local:DragDropManager.DragSourceAdvisor="{StaticResource advisor}"
local:DragDropManager.DropTargetAdvisor="{StaticResource advisor}">

You would need to implement the SourceAdvisor and TargetAdvisor (in the above example theres only one as the source and target is the same canvas). The implementation is more or less the same as in the samples provided with the library.

There were some minor glitches in the original code (such as adorner position relative to mouse) which I have fixed in the current code. Thanks to Pavan for some kewl code :)

Posted: Friday, December 08, 2006 9:36 PM by llester
Attachment(s): DragDrop.zip

Comments

Pavan Podila said:

Hi Lester,

   Thanks for your changes! I made a link to your post in this blog entry: http://pavanpodila.spaces.live.com/blog/cns!9C9E888164859398!229.entry

# December 8, 2006 7:51 PM

Life, Universe and Everything according to Dirk said:

Announcing the release of the first "WPF/E" CTP Adobe Illustrator XAML exporter for "WPF/E" The Outlook

# December 13, 2006 5:02 AM

Jan Kucera said:

Hi,

I have run 3 instances of the CanvasExample and after dragging a while, I get a fourth textbox! :) How could one avoid this? How does it work with attached events?

# December 25, 2006 5:39 AM

Microsoft SilverLight said:

SilverLight Drag and drop

# April 21, 2007 3:29 AM
New Comments to this post are disabled
Page view tracker