In my MVVM WPF application, Drag & Drop is implemented in between two ItemsControls. The DragOver & Drop methods are implemented in ItemCollectionViewModel. The Item in the ItemCollection is EquipmentViewModel model class.
In Drop Method, I am checking targetItem like below Case 1: When I am dropping on top of the the other equipment the target TargetItem is Equipment and replacement logic works fine.
if (dropInfo.TargetItem is EquipmentViewModel targetEquipment)
{
// Equipment Replacement logic
}
Case 2: When I am dropping in between the items, the dropInfo.TargetItem is ItemCollectionViewModel. Now, I can't get the insert index of the target item collection. it always add at the end.
if (dropInfo.TargetItem is ItemCollectionViewModel targetItemCollection)
{
// insert item in the targetItemCollection
}
How to get the insert index in case 2 so that item can be inserted where dropped.
