remove DragSource after adding to ListBox

Oct 19, 2009 at 7:11 AM

I am trying to modify the battery sample by disallowing the DragSource to return to its original position after being dropped in the ListBox - once it is dropped in the ListBox, it should be removed from the original source collection. I have tried setting the DropMode on the DragSource to DropDragSource but it didn't work. If I set AllDropTargetsValid to true on the DragSource of the ListBox, the result is that the ListBox moved to the place where batteries are located.  Any help is appreciated.

Oct 19, 2009 at 4:44 PM

I solved the problem by removing the DragSource from the container where it initially was in the DragSourceDropped event. I put the reference to the original DropTarget where the DragSource was attached to in the Tag element of the DragSorce element so that I can retrieve the original DropTarget in the DragSourceDropped event, then remove the original DropTarget containing the Drag Source from the container.

Still, don't quite  understand why setting the DropMode to "DropDragSource" and AllDropTargetsValid to true on the DropTarget for the ListBox didn't work...