We have three primary components to make the grouping happen. Style, GroupStyle and ListCollectionView.
First is the Window.Resource or Style:
This should be placed above the Grid node in your window. This will create the Style that will hold the Grouped Date.
Next we need GroupStyle in the actual DataGrid:
Place this below the DataGrid Properties and above the DataGrid Columns
Finally you need to load a new GroupDescription with a ListCollectionView
The below method is called on load and the ListCollectionView allows you to have a GroupDescription.Add which sets up your DataGridGroup
.
Example:
In my finally example, I have added an expander that allows me to expand and collapse on the grouped field in the DataGrid. Seems like a pretty simple task but for some reason I had a hard time figuring this one out.
Posted Code Sample:
WPFCRUDGrouping
0 comments:
Post a Comment