So I have been working on a issue with the idea of sorting the grid view on column header click. The sort works well and fast whilst the collection is small however when the collection grows to around 1 million items, the sorting can take quite a bit of time. As the sorting is performed on the UI thread the application locks out. I need to keep the application alive whilst this sorting is being performed. I have tried running this on a separate UI thread but to no avail and running this using an async call the the application dispatcher still with no joy. Please the code below illustrating the sort logic where sortBy is the bind path to sort by.
private void Sort(string sortBy, ListSortDirection direction, ListView myListView, CollectionView myCollectionView)
{
using(myCollectionView.DeferRefresh())
{
myCollectionView.SortDescription.Clear();
myCollectionView.SortDescription.Add(new SortDescription(sortBy, direction);
}
myListView.ScrollIntoView(myListView.SelectedItem);
}