NB this was for the silverlight 3 beta, RTM seems to handle grouping entirely differently.
I’ve a grid that is working fine, which I’m using the GroupDescriptions property like so:
<data:DataGrid.GroupDescriptions>
<cm:PropertyGroupDescription PropertyName="ClientName" />
</data:DataGrid.GroupDescriptions>
This works brilliantly, it’s only when the datagrid is rendered, it shows the grouping by “ClientName”. Obviously I’d like that to be “Client Name”. I cannot for the life of me see a property that would allow me to set this?
FWIW this has changed in SL3 RTM:
Silverlight 3 Beta
[Xaml]
Silverlight 3 RTM
[c#]
You need to use the PagedCollectionView class to accomplish this, it can’t be done in Xaml anymore. See http://msdn.microsoft.com/en-us/library/dd833072(VS.95).aspx
And from that link, here’s how to change the text in the group header:
When items are grouped in the DataGrid, each group has a header. You can change the appearance of the DataGridRowGroupHeader by defining a custom Style and adding it to the RowGroupHeaderStyles collection. If you have multiple levels of grouping, you can apply different styles to each group level. Styles are applied in the order in which they are defined. For example, if you define two styles, the first will be applied to top level row groups. The second style will be applied to all row groups at the second level and lower. The DataContext of the DataGridRowGroupHeader is the CollectionViewGroup that the header represents.
So a quick and dirty example would be:
In practice you probably want to include the other control parts that are specified for DataGridRowGroupHeader so that you can expand and collapse them. As with everything WPF, instead of just setting a “GroupText” property you have to go whole 9 yards!