Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drag and drop in winforms or wpf

i would like to create a simple winforms or wpf application where i can drag and drop virtual "cards". this below is not exactly what i want to do, but it the closest thing that i found on the web to represent the user interface.

http://www.greenpeppersoftware.com/confluence/plugins/advanced/gallery-slideshow.action?imageNumber=1&pageId=24870977&decorator=popup&galleryTitle=Task+board+and+transitions

so basically i want to have columns in the GUI where i can drag and drag from one to the other.

My questions are:

  1. would this be easier in winforms or wpf
  2. where do i start?
like image 353
leora Avatar asked Apr 18 '09 02:04

leora


2 Answers

In both winForms and WPF dragging and dropping can be done in a similar way by working with the events on the target DragOver and Drop.

However with WPF you have other options. You will also be able to make the application look better by having a thumbnail as you drag (this is possible in winforms but harder to achieve).

Have a look at this WPF sample it uses a helper class and think it does exactly what you need.

like image 55
John Avatar answered Sep 29 '22 22:09

John


I agree with John in that WinForms and WPF are quite close to one another w.r.t. drag'n'drop. But WPF offers more of a "common base" for ItemsControl, allowing to implement more independent of the final UI elements used (ListBox, ListView, TreeView... can be easily switched). And obviously WPF allows much more fancy effects.

I would strongly recommend this blog post: http://www.beacosta.com/blog/?p=53 both for some drag'n'drop basics and for a clean WPF drag'n'drop approach. It shows a nice implementation of a rather generic helper for drag'n'drop from/to WPF ItemsControls, I really like that "Insertion Adorner". And I do like that the drag'n'drop code is nicely separated from the user control itself by using attached properties, which makes it much easier to use and maintain.

like image 43
Simon D. Avatar answered Sep 29 '22 22:09

Simon D.