In my last post I detailed how I go about removing items from my backingList after a drag ‘n drop operation has been performed, but I didn’t mention how I went about sending that information through the drag and drop.
I think it was rather ingenious, but that could be because I’ve been awake for too long…since I control both the source and destination for the drag/drop I’m able to send the data in any method I choose. In my case I chose to send that data by just passing in the same SelectedIndexCollection used to remove those items.
This alleviates one major problem: If 20,000 items are selected I’m not creating yet another array of 20,000 items only to be used temporarily. In my testing I found trying to do a drag/drop with 20,000 items selected the app basically froze trying to copy item indices around…then I switched to using the SelectedIndexCollection and all was well.
One major caveat though: If you intend on doing updating your backing store from another thread and allow UI interaction you run the chance of the items in the SelectedIndexCollection changing while you are working with them. Calling BeginUpdate and EndUpdate on the ListView should stop that from happening, but all the same; be very careful with it.