diff --git a/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs b/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs index ac2be346..7782662e 100644 --- a/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs +++ b/src/GongSolutions.WPF.DragDrop/DragDrop.Properties.cs @@ -1614,7 +1614,7 @@ public static void SetSelectDroppedItems(DependencyObject element, bool value) } /// - /// Gets or sets the that will be used as . + /// Gets or sets the that will be used as . /// public static readonly DependencyProperty DropTargetScrollViewerProperty = DependencyProperty.RegisterAttached("DropTargetScrollViewer", @@ -1624,7 +1624,7 @@ public static readonly DependencyProperty DropTargetScrollViewerProperty /// Helper for getting from . /// to read from. - /// Gets the that will be used as . + /// Gets the that will be used as . /// DropTargetScrollViewer property value. [AttachedPropertyBrowsableForType(typeof(UIElement))] public static ScrollViewer GetDropTargetScrollViewer(DependencyObject element) @@ -1635,7 +1635,7 @@ public static ScrollViewer GetDropTargetScrollViewer(DependencyObject element) /// Helper for setting on . /// to set on. /// DropTargetScrollViewer property value. - /// Sets the that will be used as . + /// Sets the that will be used as . [AttachedPropertyBrowsableForType(typeof(UIElement))] public static void SetDropTargetScrollViewer(DependencyObject element, ScrollViewer value) { diff --git a/src/GongSolutions.WPF.DragDrop/DragDrop.cs b/src/GongSolutions.WPF.DragDrop/DragDrop.cs index ccbec639..5be9f6aa 100644 --- a/src/GongSolutions.WPF.DragDrop/DragDrop.cs +++ b/src/GongSolutions.WPF.DragDrop/DragDrop.cs @@ -467,7 +467,7 @@ private static void DoMouseButtonDown(object sender, MouseButtonEventArgs e) DragSourceDown(sender, dragInfo, e, elementPosition); } - private static void DragSourceDown(object sender, DragInfo dragInfo, InputEventArgs e, Point elementPosition) + private static void DragSourceDown(object sender, IDragInfo dragInfo, InputEventArgs e, Point elementPosition) { if (dragInfo.VisualSource is ItemsControl control && control.CanSelectMultipleItems()) { @@ -619,7 +619,7 @@ private static void DoDragSourceMove(object sender, Func g && (Math.Abs(position.X - dragStart.X) > DragDrop.GetMinimumHorizontalDragDistance(dragInfo.VisualSource) || Math.Abs(position.Y - dragStart.Y) > DragDrop.GetMinimumVerticalDragDistance(dragInfo.VisualSource))) { - dragInfo.RefreshSelectedItems(sender); + dragInfo.RefreshSourceItems(sender); var dragHandler = TryGetDragHandler(dragInfo, sender as UIElement); if (dragHandler.CanStartDrag(dragInfo)) @@ -1040,7 +1040,7 @@ private static DropTargetAdorner DropTargetAdorner } } - private static DragInfo _dragInfo; + private static IDragInfo _dragInfo; private static bool _dragInProgress; private static object _clickSupressItem; diff --git a/src/GongSolutions.WPF.DragDrop/DragInfo.cs b/src/GongSolutions.WPF.DragDrop/DragInfo.cs index 99e79a8f..d29a65d6 100644 --- a/src/GongSolutions.WPF.DragDrop/DragInfo.cs +++ b/src/GongSolutions.WPF.DragDrop/DragInfo.cs @@ -197,7 +197,8 @@ public DragInfo(object sender, object originalSource, MouseButton mouseButton, F this.SourceItems ??= Enumerable.Empty(); } - internal void RefreshSelectedItems(object sender) + /// + public virtual void RefreshSourceItems(object sender) { if (sender is not ItemsControl itemsControl) { diff --git a/src/GongSolutions.WPF.DragDrop/DropInfo.cs b/src/GongSolutions.WPF.DragDrop/DropInfo.cs index 909fd273..1d1fa060 100644 --- a/src/GongSolutions.WPF.DragDrop/DropInfo.cs +++ b/src/GongSolutions.WPF.DragDrop/DropInfo.cs @@ -96,14 +96,10 @@ public int UnfilteredInsertIndex /// public CollectionViewGroup TargetGroup { get; protected set; } - /// - /// Gets the ScrollViewer control for the visual target. - /// + /// public ScrollViewer TargetScrollViewer { get; protected set; } - /// - /// Gets or Sets the ScrollingMode for the drop action. - /// + /// public ScrollingMode TargetScrollingMode { get; set; } /// diff --git a/src/GongSolutions.WPF.DragDrop/DropTargetAdorner.cs b/src/GongSolutions.WPF.DragDrop/DropTargetAdorner.cs index adfa2d29..f335c536 100644 --- a/src/GongSolutions.WPF.DragDrop/DropTargetAdorner.cs +++ b/src/GongSolutions.WPF.DragDrop/DropTargetAdorner.cs @@ -59,7 +59,13 @@ internal static DropTargetAdorner Create(Type type, UIElement adornedElement, ID throw new InvalidOperationException("The requested adorner class does not derive from DropTargetAdorner."); } - return type.GetConstructor(new[] { typeof(UIElement), typeof(DropInfo) })?.Invoke(new object[] { adornedElement, dropInfo }) as DropTargetAdorner; + var ctor = type.GetConstructor(new[] { typeof(UIElement), typeof(IDropInfo) }); + if (ctor is null && dropInfo is DropInfo) + { + ctor = type.GetConstructor(new[] { typeof(UIElement), typeof(DropInfo) }); + } + + return ctor?.Invoke(new object[] { adornedElement, dropInfo }) as DropTargetAdorner; } } } \ No newline at end of file diff --git a/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs b/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs index b2a248f2..82abaef7 100644 --- a/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs +++ b/src/GongSolutions.WPF.DragDrop/DropTargetInsertionAdorner.cs @@ -9,7 +9,7 @@ namespace GongSolutions.Wpf.DragDrop { public class DropTargetInsertionAdorner : DropTargetAdorner { - public DropTargetInsertionAdorner(UIElement adornedElement, DropInfo dropInfo) + public DropTargetInsertionAdorner(UIElement adornedElement, IDropInfo dropInfo) : base(adornedElement, dropInfo) { } diff --git a/src/GongSolutions.WPF.DragDrop/IDragInfo.cs b/src/GongSolutions.WPF.DragDrop/IDragInfo.cs index bbd78542..94820728 100644 --- a/src/GongSolutions.WPF.DragDrop/IDragInfo.cs +++ b/src/GongSolutions.WPF.DragDrop/IDragInfo.cs @@ -119,5 +119,11 @@ public interface IDragInfo /// Gets the drag drop copy key state indicating the effect of the drag drop operation. /// DragDropKeyStates DragDropCopyKeyState { get; } + + /// + /// Refreshes the property. + /// + /// The drag source control. + void RefreshSourceItems(object sender); } } \ No newline at end of file diff --git a/src/GongSolutions.WPF.DragDrop/IDragInfoBuilder.cs b/src/GongSolutions.WPF.DragDrop/IDragInfoBuilder.cs index 05d3c897..084302e2 100644 --- a/src/GongSolutions.WPF.DragDrop/IDragInfoBuilder.cs +++ b/src/GongSolutions.WPF.DragDrop/IDragInfoBuilder.cs @@ -19,6 +19,6 @@ public interface IDragInfoBuilder /// The mouse button which was used for the drag operation. /// A function of the input event which is used to get drag position points. [CanBeNull] - DragInfo CreateDragInfo(object sender, object originalSource, MouseButton mouseButton, Func getPosition); + IDragInfo CreateDragInfo(object sender, object originalSource, MouseButton mouseButton, Func getPosition); } } \ No newline at end of file diff --git a/src/GongSolutions.WPF.DragDrop/IDragSource.cs b/src/GongSolutions.WPF.DragDrop/IDragSource.cs index 87df47f1..b4b333ab 100644 --- a/src/GongSolutions.WPF.DragDrop/IDragSource.cs +++ b/src/GongSolutions.WPF.DragDrop/IDragSource.cs @@ -13,7 +13,7 @@ public interface IDragSource /// /// Object which contains several drag information. /// - /// To allow a drag to be started, the property on + /// To allow a drag to be started, the property on /// should be set to a value other than . /// void StartDrag(IDragInfo dragInfo); diff --git a/src/GongSolutions.WPF.DragDrop/IDropInfoBuilder.cs b/src/GongSolutions.WPF.DragDrop/IDropInfoBuilder.cs index aba25dda..233cbd5c 100644 --- a/src/GongSolutions.WPF.DragDrop/IDropInfoBuilder.cs +++ b/src/GongSolutions.WPF.DragDrop/IDropInfoBuilder.cs @@ -17,6 +17,6 @@ public interface IDropInfoBuilder /// Information about the drag source, if the drag came from within the framework. /// The type of the underlying event (tunneled or bubbled). [CanBeNull] - IDropInfo CreateDropInfo(object sender, DragEventArgs e, [CanBeNull] DragInfo dragInfo, EventType eventType); + IDropInfo CreateDropInfo(object sender, DragEventArgs e, [CanBeNull] IDragInfo dragInfo, EventType eventType); } } \ No newline at end of file diff --git a/src/GongSolutions.WPF.DragDrop/IDropTarget.cs b/src/GongSolutions.WPF.DragDrop/IDropTarget.cs index 037bf923..5b482b53 100644 --- a/src/GongSolutions.WPF.DragDrop/IDropTarget.cs +++ b/src/GongSolutions.WPF.DragDrop/IDropTarget.cs @@ -38,9 +38,9 @@ void DragEnter(IDropInfo dropInfo) /// /// Object which contains several drop information. /// - /// To allow a drop at the current drag position, the property on + /// To allow a drop at the current drag position, the property on /// should be set to a value other than - /// and should be set to a non-null value. + /// and should be set to a non-null value. /// void DragOver(IDropInfo dropInfo); diff --git a/src/Showcase/Models/TextBoxCustomDropHandler.cs b/src/Showcase/Models/TextBoxCustomDropHandler.cs index f7a51a90..17dc2276 100644 --- a/src/Showcase/Models/TextBoxCustomDropHandler.cs +++ b/src/Showcase/Models/TextBoxCustomDropHandler.cs @@ -69,7 +69,7 @@ public class DropTargetHighlightAdorner : DropTargetAdorner private readonly Pen _pen; private readonly Brush _brush; - public DropTargetHighlightAdorner(UIElement adornedElement, DropInfo dropInfo) + public DropTargetHighlightAdorner(UIElement adornedElement, IDropInfo dropInfo) : base(adornedElement, dropInfo) { this._pen = new Pen(Brushes.Tomato, 2);