This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product. Otherwise - post away!
How do I sort the DataGrid programatically? I've tried getting the DataGridColumn and setting the SortDirection property. That updates the sort direction of the arrow in the heading, but doesn't seem to apply a sort to the items. My ItemsSource is an ObservableCollection<>. If I click the heading using the mouse, then sorting works as expected.
Also, I've noticed that if the DataGrid is sorted by a column and I add a new item to the ItemsSource (ObservableCollection<>), the item gets added at the end. I would like to see the sort be applied (because there is an indicator in the heading showing that the data is sorted by that particular column, but the new item is not sorted into its correct position) when the collection changes or have a way to "refresh" or apply the sort logic again.
One other item, I'm wondering about multi-column sorting. If I wanted to apply a multi-level sort programatically, how would I do that? With the WPF DataGrid, I used to add a SortDescription for each column I wanted to sort by (see below).
I know I could sort the underlying collection that I use for my ItemsSource, but I was wondering if there is anything built into the Mindscape DataGrid for this.
To programatically sort the data grid, you can use the DataGrid.DisplayedItemsSource property to get the DataGridItemsSource instance. Here you can call one of its Sort methods to apply sorting.
At the moment when you add an item to the collection, you'll need to refresh the sorting as I described above. I've fixed the column headers to become unhighlighted when the displayed items are no longer sorted. (e.g. an item is added)
There currently is no built in multi-level sorting, but for now you can at least create a custom IComparer that performs multi-level sorting which you can pass into the Sort method.
Thanks for all this feedback! These points will be considered when improving the sorting capabilities in future updates.