I have a listView displaying a bunch of graphs. I can sort this listview using different criteria. Unfortunately when I perform sort, the operation took more time than expected and I realized that after the sort was triggered all the graphs were being recreated.
My datasource is an observable collection and the view consists of a chart control and a few labels. I perform the sort on the view by using the view sort description, so the sort should be performed on the view and not on the data source, right?
lstView.Items.SortDescriptions.Clear();
lstView.Items.SortDescriptions.Add(new SortDescription(_field, _lstViewDirection));
I have been searching around and it seems that the sort triggers a refresh which removes the UI elements from the control and recreates them ... but this seems unnecessary given I am only ordering the positions of the UI elements.
Is there a way to avoid this refresh behaviour and only reorder the UI elements positions?
You need to use Virtualization so only the elements displayed in the UI are redrawn instead of the entire collection.
http://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx