I'm using the ListBoxDragDropTarget
from the Silverlight Toolkit (April 2010) with SL 4.
I want to drag items from the list box onto a Label
and handle the drop event there.
However it seems a bit complicated. The regular Drop
event of the Label
never gets fired. I suppose that is because the Silverlight Toolkit has its own way of handling Drag & Drop which is only partially compatible.
Looking arround I found the Microsoft.Windows.DragDrop.DropEvent
and attached a handler to this event. And it worked!! I got the Drop
event. However I'm not sure how to get to the real object that was dragged (a string
).
I tried e.Data.GetData(typeof(string))
but I got nothing. Looking at the available formats there is a System.Windows.Controls.ItemDragEventArgs
object. Inside this I found an array of System.Collections.ObjectModel.Selection
which then has an Item property. I suppose in this Item property I find my object, but the whole method seems a bit fragile and I'm not convinced that is the official way to do this.
Is there any better way?