diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/ExtensionMethods')
| -rw-r--r-- | Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs index d7161953f..948be3c4a 100644 --- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs @@ -41,5 +41,18 @@ public static class ObservableCollectionExtensions collection[index1] = collection[index2]; collection[index2] = tmp; } + + /// <summary> + /// Removes the dragged element and inserts it after the dropped element position. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="collection">The collection.</param> + /// <param name="dragged">The dragged element.</param> + /// <param name="dropped">The dropped element.</param> + public static void DragAndDrop<T>(this ObservableCollection<T> collection, T dragged, T dropped) + { + collection.Remove(dragged); + collection.Insert(collection.IndexOf(dropped), dragged); + } } |
