In my WPF application I need to implement the drag and drop functionality like windows explorer shell. I have had a look at canvas and it was pretty good but then since we wanted items to be aligned, went in to add dummy items into the ObservableCollection. Now I'm able to add dummy items in the ObservableCollection and also able to swap 2 items in Observable Collection. The problem is when the program starts, it takes time to load since I have added dummy items and on replacing items, a new ObservableCollection is generated which replaces the current Collection. So how do I increase the speed? Either I can fix this or may be I'm heading the wrong direction for replacing items. Can anyone advice?
Code to swap the ObservableCollection.
static ObservableCollection<T> Swap<T>(IList<T> list, int indexA, int indexB)
{
if (indexA != -1 && indexB != -1)
{
T tmp = list[indexA];
list[indexA] = list[indexB];
list[indexB] = tmp;
}
return new ObservableCollection<T>(list);
}
This is how I call it:
AppsList = Swap<ItemTemplate>(AppsList, targetIndex, selectedIndex);
I need to improve User experience so that this delay is not noticed. If I can eliminate the delay,there's nothing like it.