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

Drag source ignore issue in ListView #350

Closed
YohskDista opened this issue Apr 30, 2020 · 2 comments · Fixed by #364
Closed

Drag source ignore issue in ListView #350

YohskDista opened this issue Apr 30, 2020 · 2 comments · Fixed by #364
Labels
Milestone

Comments

@YohskDista
Copy link
Contributor

Hello everyone,

I want to thank you very much for this library that always helped me in every project where I need to code Drag&Drop feature. I open this issue for a corner case that I discovered today, here is the explanation :

Issue

I have a problem with the DragSourceIgnore property that is not working totally. In a ListView WPF control I set for each ListViewItem the dragdrop:DragDrop.DragSourceIgnore to True. The only way to move the ListViewItem is to left click with the mouse on the drag icon on the left (like in the image below).

image

The problem is, when we go at the bottom of the list and you left click (like you want to drag something) on the red area here below, the last module is dragged in the list.

image

image

Steps to reprodue

To reproduce this issue you can use the Showcase.WPF.DragDrop.exe that you have created and select the example : Mixed -> Cloning

Expected outcome

Don't drag the module if we are in an ignored area.

Environment

  • GongSolutions.WPF.DragDrop v2.2.0
  • Windows OS 10
  • Visual Studio 2019
  • .NET Framework 4.7
@YohskDista
Copy link
Contributor Author

Perhaps it is better with a GIF than a long explanation :

DragDropError

Thank you in advance for your help !

@punker76 punker76 added the Bug label Jun 24, 2020
@YohskDista
Copy link
Contributor Author

I checked a little bit the code and search what could be the cause. I found that in the DragDrop.cs class in the DoMouseButtonDown method you test if we are in a drag situation or not. When we drag the empty space (as shown in the GIF) we have the drag OriginalSource that is a ScrollViewer type. According to the comment above the condition :

// Ignore the click if clickCount != 1 or the user has clicked on a scrollbar.

I could not find the exact line where we are testing if the user has clicked on a scrollbar/scrollviewer :

var elementPosition = e.GetPosition((IInputElement)sender);
if (e.ClickCount != 1
    || (sender as UIElement).IsDragSourceIgnored()
    || (e.Source as UIElement).IsDragSourceIgnored()
    ||  (e.OriginalSource as UIElement).IsDragSourceIgnored()
    || (sender is TabControl) && !HitTestUtilities.HitTest4Type<TabPanel>(sender, elementPosition)
    || HitTestUtilities.HitTest4Type<RangeBase>(sender, elementPosition)
    || HitTestUtilities.HitTest4Type<TextBoxBase>(sender, elementPosition)
    || HitTestUtilities.HitTest4Type<PasswordBox>(sender, elementPosition)
    || HitTestUtilities.HitTest4Type<ComboBox>(sender, elementPosition)
    || HitTestUtilities.HitTest4GridViewColumnHeader(sender, elementPosition)
    || HitTestUtilities.HitTest4DataGridTypes(sender, elementPosition)
    || HitTestUtilities.IsNotPartOfSender(sender, e))
{
   return;
}

I tried to add this test in the condition :

|| e.OriginalSource is ScrollViewer

And, after testing each showcase present in the Showcase.WPF.DragDrop project, it seems to work but I am not sure if it is a wanted behavior or not.

What do you think ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants