Export (0) Print
Expand All

DataGrid.GetGroupFromItem Method

Gets the row group that the specified item belongs to.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)

public CollectionViewGroup GetGroupFromItem(
	Object item,
	int groupLevel
)

Parameters

item
Type: System.Object
The item to find the group for.
groupLevel
Type: System.Int32
The group sub level that the item is in.

Return Value

Type: System.Windows.Data.CollectionViewGroup
The row group that the specified item belongs to.

You can use the GetGroupFromItem method to get the CollectionViewGroup that a specified item belongs to. The CollectionViewGroup can be passed to the ExpandRowGroup and CollapseRowGroup methods.

The following code example demonstrates how to get the CollectionViewGroup that the currently selected item belongs to.

[Visual Basic]

Dim cvg = dataGrid1.GetGroupFromItem(dataGrid1.SelectedItem, 0)

[C#]

CollectionViewGroup cvg = dataGrid1.GetGroupFromItem(dataGrid1.SelectedItem, 0);

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.

Community Additions

Show:
© 2014 Microsoft