0 out of 1 rated this helpful - Rate this topic

DataGrid.ExpandRowGroup Method

Silverlight

Expands data grid row groups.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)
public void ExpandRowGroup(
	CollectionViewGroup collectionViewGroup,
	bool expandAllSubgroups
)

Parameters

collectionViewGroup
Type: System.Windows.Data.CollectionViewGroup
The data in the row group.
expandAllSubgroups
Type: System.Boolean
true to expand all subgroups of the row group; otherwise, false.

You can call this method to programmatically expand row groups in a DataGrid control that contains grouped data. You can use the GetGroupFromItem method to get the particular group that a specified item belongs to. Alternatively, you can iterate through the Groups collection to expand all row groups.

The following example demonstrates how to expand all row groups in a DataGrid control. This example is part of a larger example available in the How to: Group, Sort, and Filter Data in the DataGrid Control topic.


private void ExpandButton_Click(object sender, RoutedEventArgs e)
{
    PagedCollectionView pcv = dataGrid1.ItemsSource as PagedCollectionView;
    try
    {
        foreach (CollectionViewGroup group in pcv.Groups)
        {
            dataGrid1.ExpandRowGroup(group, true);
        }
    }
    catch (Exception ex)
    {
        // Could not expand group.
        MessageBox.Show(ex.Message);
    }
}


Silverlight

Supported in: 5, 4, 3

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ