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

add SourceIndex to DragInfo #79

Merged
merged 1 commit into from
Oct 14, 2013
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions GongSolutions.Wpf.DragDrop/DragInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -132,6 +135,12 @@ public DragInfo(object sender, MouseButtonEventArgs e)
/// </remarks>
public IEnumerable SourceCollection { get; private set; }

/// <summary>
/// Gets the position from where the item was dragged.
/// </summary>
/// <value>The index of the source.</value>
public int SourceIndex { get; private set; }

/// <summary>
/// Gets the object that a dragged item is bound to.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions GongSolutions.Wpf.DragDrop/IDragInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public interface IDragInfo
/// </remarks>
IEnumerable SourceCollection { get; }

/// <summary>
/// Gets the position from where the item was dragged.
/// </summary>
int SourceIndex { get; }

/// <summary>
/// Gets the object that a dragged item is bound to.
/// </summary>
Expand Down