Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
punker76 opened this issue Feb 18, 2013 · 2 comments

Comments

@punker76
Copy link
Owner

Original author: braul...@gmail.com (November 15, 2012 23:44:01)

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).
  4. Set the datacontext of LBA to a viewModel instance of type A.
  5. Set the datacontext of LBB to a viewmodel instance of type B
  6. Set the IsDragSource and DragHandler to LBA
  7. Set the IsDropTarget and DropHandler to LBB
  8. 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: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=49

@punker76
Copy link
Owner Author

From braul...@gmail.com on November 20, 2012 15:29:52
Note: My fix is not working when you drop something from an external application

punker76 pushed a commit that referenced this issue Apr 5, 2013
The Dropped function from IDragSource is called on the target and not
the Source
@punker76
Copy link
Owner Author

punker76 commented Apr 5, 2013

will be published in 0.1.3.7

@punker76 punker76 closed this as completed Apr 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant