Is there an example implementation of Drag & Drop at runtime using C# code? The only examples I've seen are in Xaml.
I need to Drag and Drop between a collection of XamTree's and a ListBox. Also, need to move XamTreeItems around within a Tree. These trees are created dynamically at runtime.
Thanks Nikolay. Just what I needed.
Hi,
Setting Drag & Drop at runtime using C# is pretty much the same as setting it from xaml. The only special thing that you should know is that DragDropManager.DropTarget and DragDropManager.DragSource are attached properties and setting them from C# can be done like this:
item1.SetValue(DragDropManager.DragSourceProperty, ds); // ds is an object of type DragSource
I've attached a sample that demonstrates this approach.
Regards,