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 Function GetGroupFromItem ( _
	item As Object, _
	groupLevel As Integer _
) As CollectionViewGroup


Type: System.Object
The item to find the group for.
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)


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


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