Upon dropping an object onto a target, the index passed to remove the item from the source collection is the ItemContainer index. If the bound ItemsSource (in my case TreeView.ItemsSource) is a ICollectionView that has been filtered, this index is wrong. One of two things must be changed. Either the index to remove must be the index within the source collection of the ICollectionView or you must update the code in CollectionHelper.RemoveAt(this IEnumerable collection, int index) to not check for ICollectionView (the first If statement in this method) and simply call the RemoveAt function (in the else block of this method). The second option is best I believe. The collection view implementation should handle the RemoveAt properly rather than the DragDropTarget class(es) assuming that it should be removed from the ICollectionView.SourceCollection.
Comments: ** Comment from web user: cmlawson **
Comments: ** Comment from web user: cmlawson **
To be more succinct, when the ItemsSource is bound to an ICollectionView, the index obtained by the DragDropTarget classes is the ICollectionView's index NOT the ICollectionView.SourceCollection index. In most implementations they are the same, which is why the bug was not encountered. If you apply a filter to the ICollectionView, then the indexes are not the same. So, during the drag/drop operation the wrong item from Source collection is removed.