rodriwasabi / gong-wpf-dragdrop

Automatically exported from code.google.com/p/gong-wpf-dragdrop
0 stars 1 forks source link

The Dropped function from IDragSource is called on the target and not the Source #49

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a ViewModel class A and implement IDragSource
2. Create a ViewModel class B and implement IDropTarget
3. Create two ListBox (named LBA and LBB).
5. Set the datacontext of LBA to a viewModel instance of type A.
6. Set the datacontext of LBB to a viewmodel instance of type B
7. Set the IsDragSource and DragHandler to LBA
8. Set the IsDropTarget and DropHandler to LBB
9. Try to move items from LBA to LBB

What is the expected output? What do you see instead?
I would like the Dropped function on my view model A to be called when a drop 
occurs
Instead of the one ine the DefaultDragHandler

What version of the product are you using? On what operating system?
Last one, Windows 7

Please provide any additional information below.

Looking at the code, it seems that the issue came from 
file: DragDrop.cs
function: static void DropTarget_PreviewDrop(object sender, DragEventArgs e)
Line: IDragSource dragHandler = GetDragHandler((UIElement)sender) ?? 
DefaultDragHandler;

We are getting the DragSource of the sender uiElement which is the target one 
(i.e. LBB)

I fixed it by replacing the line with this one:
IDragSource dragHandler = GetDragHandler(_DragInfo.VisualSource) ?? 
DefaultDragHandler;

Original issue reported on code.google.com by braul...@gmail.com on 15 Nov 2012 at 11:44

GoogleCodeExporter commented 8 years ago
Note: My fix is not working when you drop something from an external application

Original comment by braul...@gmail.com on 20 Nov 2012 at 3:29