Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF drag & drop between containers

I've got a container, say a Grid. It has two containers, say StackPanels.

StackPanel #1 has some rectangles. What's the best way to enable a user to drag a rectangle and drop it in the StackPanel #2 (and have that rectangle be a child of StackPanel #2).

I've got the drag bit sussed - the only thing that's unclear is whether to actually use containers or just handle all the rectangles manually in a straight canvas.

like image 463
Steve Dunn Avatar asked Apr 21 '09 12:04

Steve Dunn


1 Answers

As far as the logic behind actually moving the items goes, a StackPanel as a container is just fine. If you want to preview the item whilst it's being dragged, you can implement an Adorner that displays the Visual whilst it is being dragged.

like image 165
Kent Boogaart Avatar answered Oct 14 '22 07:10

Kent Boogaart