Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions GongSolutions.Wpf.DragDrop/DragDrop.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections;
using System.Linq;
using System.Net;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
Expand Down Expand Up @@ -333,7 +335,21 @@ public static void SetDragMouseAnchorPoint(UIElement target, Point value)
target.SetValue(DragMouseAnchorPointProperty, value);
}

public static IDragSource DefaultDragHandler

public static readonly DependencyProperty ScrollDelayProperty = DependencyProperty.RegisterAttached(
"ScrollDelay", typeof(double), typeof(DragDrop), new PropertyMetadata(default(double)));

public static void SetScrollDelay(DependencyObject element, double value)
{
element.SetValue(ScrollDelayProperty, value);
}

public static double GetScrollDelay(DependencyObject element)
{
return (double) element.GetValue(ScrollDelayProperty);
}

public static IDragSource DefaultDragHandler
{
get
{
Expand Down Expand Up @@ -932,7 +948,24 @@ itemsControl is TabControl
e.Effects = DragDropEffects.None;
}

Scroll(dropInfo.VisualTarget, e);

if (_canScroll)
{
_canScroll = false;
Scroll(dropInfo.VisualTarget, e);
var interval = GetScrollDelay(m_DragInfo.VisualSource);
if (interval > 0)
{
_canScrollDelayTimer.Interval = interval;
_canScrollDelayTimer.Start();
}
else
{
_canScroll = true;
}

}

}

private static void DropTarget_PreviewDrop(object sender, DragEventArgs e)
Expand Down Expand Up @@ -1013,5 +1046,13 @@ private static DropTargetAdorner DropTargetAdorner
private static object m_ClickSupressItem;
private static Point _adornerPos;
private static Size _adornerSize;

private static bool _canScroll = true;
private static readonly Timer _canScrollDelayTimer = new Timer();

static DragDrop()
{
_canScrollDelayTimer.Elapsed += (sender, args) => _canScroll = true;
}
}
}