Xceed DataGrid for WPF v7.2 Documentation
GetChildContexts Method (DataGridContext)
Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > DataGridContext Class : GetChildContexts Method
Retrieves the child DataGridContexts of the context.
Syntax
'Declaration
 
Public Function GetChildContexts() As IEnumerable(Of DataGridContext)
'Usage
 
Dim instance As DataGridContext
Dim value As IEnumerable(Of DataGridContext)
 
value = instance.GetChildContexts()
public IEnumerable<DataGridContext> GetChildContexts()

Return Value

An IEnumerable that contains the child DataGridContexts of the context. Can be empty if the context does not have child contexts.
Example

All examples in this topic assume that the grid is bound to the Employees table of the Northwind database, unless stated otherwise.

The following example demonstrates how to retrieve the child contexts of the master data items and collapse any expanded details using the CollapseDetail method.The next example provides the implementation of the button's Click event.The next example provides the implementation of the button's Click event.
<Grid>
  <Grid.Resources>
     <xcdg:DataGridCollectionViewSource x:Key="cvs_employees"
                                        Source="{Binding Source={x:Static Application.Current},
                                                         Path=Employees}"/>
 
  </Grid.Resources>
 
  <DockPanel>
     <Button Content="Collapse All Details"
             Click="Button_Click"
             DockPanel.Dock="Top"/>
     <xcdg:DataGridControl x:Name="EmployeesGrid"
                           ItemsSource="{Binding Source={StaticResource cvs_employees}}"
                           ItemsSourceName="Order Information"
                           AutoCreateDetailConfigurations="True"/>
  </DockPanel>
</Grid>
Private Sub Button_Click( ByVal sender As Object, ByVal e As RoutedEventArgs )
  DataGridContext rootContext = DataGridControl.GetDataGridContext( this.EmployeesGrid );

  Dim childContexts As New List( Of DataGridContext)( Me.EmployeesGrid.GetChildContexts() )

  Dim context As DataGridContext
  For Each context In childContexts
    context.ParentDataGridContext.CollapseDetails( context.ParentItem )
  Next context
End Sub
private void Button_Click( object sender, RoutedEventArgs e )
{
 DataGridContext rootContext = DataGridControl.GetDataGridContext( this.EmployeesGrid );

 List<DataGridContext> childContexts = new List<DataGridContext>( this.EmployeesGrid.GetChildContexts() );

 foreach( DataGridContext context in childContexts )
 {
   context.ParentDataGridContext.CollapseDetails( context.ParentItem );
 }     
}
Requirements

Target Platforms: Windows 11, Windows, 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

DataGridContext Class
DataGridContext Members