DataGrid.GetGroupFromItem Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
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)
Syntax
'Declaration
Public Function GetGroupFromItem ( _
item As Object, _
groupLevel As Integer _
) As CollectionViewGroup
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.
Remarks
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.
Examples
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);
Version Information
Silverlight
Supported in: 5, 4, 3
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
See Also