From 05aa38279a6721289900416c27b71d7d0cb5f786 Mon Sep 17 00:00:00 2001 From: punker76 Date: Mon, 14 Oct 2013 23:22:15 +0200 Subject: [PATCH] add SourceIndex to DragInfo --- GongSolutions.Wpf.DragDrop/DragInfo.cs | 9 +++++++++ GongSolutions.Wpf.DragDrop/IDragInfo.cs | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/GongSolutions.Wpf.DragDrop/DragInfo.cs b/GongSolutions.Wpf.DragDrop/DragInfo.cs index 94707653..fa5a653b 100644 --- a/GongSolutions.Wpf.DragDrop/DragInfo.cs +++ b/GongSolutions.Wpf.DragDrop/DragInfo.cs @@ -62,7 +62,10 @@ public DragInfo(object sender, MouseButtonEventArgs e) if (itemParent != null) { this.SourceCollection = itemParent.ItemsSource ?? itemParent.Items; + this.SourceIndex = itemParent.ItemContainerGenerator.IndexFromContainer(item); this.SourceItem = itemParent.ItemContainerGenerator.ItemFromContainer(item); + } else { + this.SourceIndex = -1; } this.SourceItems = itemsControl.GetSelectedItems(); @@ -132,6 +135,12 @@ public DragInfo(object sender, MouseButtonEventArgs e) /// public IEnumerable SourceCollection { get; private set; } + /// + /// Gets the position from where the item was dragged. + /// + /// The index of the source. + public int SourceIndex { get; private set; } + /// /// Gets the object that a dragged item is bound to. /// diff --git a/GongSolutions.Wpf.DragDrop/IDragInfo.cs b/GongSolutions.Wpf.DragDrop/IDragInfo.cs index 91f156e6..81111c76 100644 --- a/GongSolutions.Wpf.DragDrop/IDragInfo.cs +++ b/GongSolutions.Wpf.DragDrop/IDragInfo.cs @@ -49,6 +49,11 @@ public interface IDragInfo /// IEnumerable SourceCollection { get; } + /// + /// Gets the position from where the item was dragged. + /// + int SourceIndex { get; } + /// /// Gets the object that a dragged item is bound to. ///