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.
↧