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

Bubbling events #15

Closed
punker76 opened this issue Feb 18, 2013 · 1 comment
Closed

Bubbling events #15

punker76 opened this issue Feb 18, 2013 · 1 comment

Comments

@punker76
Copy link
Owner

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

@ghost ghost assigned punker76 Jun 5, 2013
punker76 pushed a commit that referenced this issue Jun 5, 2013
a drop target can now be placed on a child element of a grid, listbox or something else (more mvvm like)
the NotHandled property can be used to allow bubbling the drag over event.
@punker76
Copy link
Owner Author

punker76 commented Jun 5, 2013

this issue will be published in 0.1.3.7

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