Drag and Drop (WPF)

Ok guys, I scratched my head like crazy on this issue, and spent many hours trying to research how it works, but I haven't found an answer yet.

Basically the problem I am facing is that I have a folder tree in my ie application:

Catalog

  Brands
    Nike
    Adidas
    Lactose


  Styles
    Sandles
    Trainers
    Boots

The problem I'm trying to fix is ​​that when I drag and drop a folder (this is handled in my DragDropManager class), I cannot scroll up or down (it just displays a fine stop sign).

This is a problem if I want to move something from the top to the bottom.

Scrolling works fine without drag and drop.

If anyone wants to see any part of my code, feel free to ask, as I'm not sure what to actually show you guys.

.

+3
1

, :

  • (QueryContinueDrag) , ScrollViewer .

  • , scrollviewer, . 10px.

  • scrollviewer

:

ScrollViewer:

var _scrollViewerControl = FindVisualChild<ScrollViewer>(treeView);

private childItem FindVisualChild<childItem>(DependencyObject obj)
where childItem : DependencyObject
{
  for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
  {
    DependencyObject child = VisualTreeHelper.GetChild(obj, i);
    if (child != null && child is childItem)
      return (childItem)child;
    else
    {
      childItem childOfChild = FindVisualChild<childItem>(child);
      if (childOfChild != null)
        return childOfChild;
    }
  }
  return null;
}

QueryContinueDrag delta scrollviewer:

// as we don't have eventargs here exposing the current mouse position we use the
// win32 API to get the current mouse position
Win32.POINT p;
if (!Win32.GetCursorPos(out p))
{
    return;
}

//this is the point on the screen
Point point = new Point(p.X, p.Y);

//get position relative to scrollViewerControl
Point controlPoint = _scrollViewerControl.PointFromScreen(point);

if (controlPoint.Y < 10 && -10 < controlPoint.Y)
{
    _scrollViewerControl.LineUp();
}
else if (controlPoint.Y > _scrollViewerControl.ViewportHeight - 10 && _scrollViewerControl.ViewportHeight + 10 > controlPoint.Y)
{
    _scrollViewerControl.LineDown();
}

if (controlPoint.X < 10 && -10 < controlPoint.X)
{
    _scrollViewerControl.LineLeft();
}
else if (controlPoint.X > _scrollViewerControl.ViewportWidth - 10 && _scrollViewerControl.ViewportWidth + 10 > controlPoint.X)
{
    _scrollViewerControl.LineRight();
}
+2

All Articles