punker76 / gong-wpf-dragdrop

The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bubbling events

punker76 opened this issue · comments

Original author: b.a.roys...@gmail.com (May 21, 2010 06:45:03)

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.

Original issue: http://code.google.com/p/gong-wpf-dragdrop/issues/detail?id=15

this issue will be published in 0.1.3.7