Export to GitHub

gong-wpf-dragdrop - issue #15

Bubbling events


Posted on May 21, 2010 by Quick Cat

What steps will reproduce the problem? 1. Place a droptarget on a Grid 2. Inside the grid, place a new droptarget on a child element of the grid

Since I'm using MVVM I have a different ViewModel for the child element, thus also a different event handler for dropping an element of a different type than dropped onto the parent Grid.

What is the expected output? What do you see instead? The grid will handle the event and the dragOver event will never trigger on the child

What version of the product are you using? On what operating system? 1.1 on WinXP

Please provide any additional information below.

I circumvented this by adding a new property in DragInfo called "IsNotHandled" (inverted to apply default behaviour in this case) In the DragDrop class I changed the following code;

static void DropTarget_PreviewDragOver(object sender, DragEventArgs e) { ...

e.Handled = !dropInfo.IsNotHandled; // Allows bubbling
Scroll((DependencyObject)sender, e);

}

and

static void DropTarget_PreviewDrop(object sender, DragEventArgs e) { ...

e.Handled = !dropInfo.IsNotHandled; // Allows bubbling

}

In the handler for my Grid I've added the following code:

public void DragOver(DropInfo dropInfo) { if (dropInfo.Data is ButtonLayoutViewModel || dropInfo.Data is JoystickLayoutViewModel) { dropInfo.DropTargetAdorner = DropTargetAdorners.Highlight; dropInfo.Effects = DragDropEffects.Copy; } else { dropInfo.IsNotHandled = true; // Allows the event to bubble to the next element } }

This resolved my issue of allowing drop onto a child viewmodel on a viewmodel.

Comment #1

Posted on May 18, 2013 by Grumpy Horse

I had this problem as well, my scenario:

  • Dropping an object into a list adds a new item
  • Dragging a list item within the list changes the order
  • Dragging a list item outside to the parent container removes it from the list

Your patch worked perfectly. I have added it to my fork here https://github.com/rdingwall/gong-wpf-dragdrop.

Many thanks, Rich

Status: New

Labels:
Type-Defect Priority-Medium