I can't seem to find a way to specify that it sorts on the group name first, then the column. I am using the DataGrid.
EDIT: My mistake, I am using the DataGrid, not the Grid.
I can't seem to find a way to specify that it sorts on the group name first, then the column. I am using the DataGrid.
EDIT: My mistake, I am using the DataGrid, not the Grid.
A Grid is not a data control (like a DataGrid) so other than manually sorting and then adding the other items one-by-one, there's really no clean way to do it.
You need to think of a Grid as a XAML version of an HTML Table tag.
EDIT (OP changed from Grid to DataGrid, adding the following):
Support for sorting the DataGrid is built in for sorting any collection that implements the
IList
interface. If you're usingAutoGenerateColumns
that's all there is too it. But that's not what it sounds like you're wanting to do.It sounds like you're trying to do it programatically. What you need to do is set the
SortMemberPath
of the column. If you're manually creating the columns, it's just a property on the column. If you're using autogeneration, you can do it in theAutoGeneratingColumn
event.You can do it in XAML too by just setting the property for the column, if you're creating the column manually in XAML too.
Bear in mind that these are just general instructions for sorting in a DataGrid. For a more involved sort such as you are inquiring about, you'll want to sort the data source you're using, i.e. the collection that you're binding the grid to.
What I'm unsure of is what you mean by "the group name first, then the column". Are you meaning group name as a default sort and then column sortation if the user desires? If so, these instructions should help. If not, I'm unsure what you mean.