Xceed DataGrid for WPF v7.3 Documentation
Xceed.Wpf.DataGrid Assembly / Xceed.Wpf.DataGrid Namespace / DataGridContext Class
Members Example


In This Topic
    DataGridContext Class
    In This Topic
    Class that the provides contextual information on, and access to, items contained in a grid or detail.
    Syntax
    'Declaration
     
    <TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>
    <NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>
    Public NotInheritable Class DataGridContext 
       Inherits System.Windows.DependencyObject
    'Usage
     
    Dim instance As DataGridContext
    [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
    [NameScopeProperty("NameScope", System.Windows.NameScope)]
    public sealed class DataGridContext : System.Windows.DependencyObject 
    Remarks
    The data-grid context of a grid always exists; however, detail contexts are created and exist only when they are expanded and will be destroyed when a detail is collapsed. A data-grid context's HasDetails property can be queried to determine if it has details; however, it does not indicate whether the details are expanded and consequently have a context. To know if the details of a specific data item are expanded and therefore have a context, the AreDetailsExpanded method can be used.
    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 provide a default detail configuration that will be applied to all details in a grid and any descendant details for which an explicit detail configuration has not been provided.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}" />
       
         <xcdg:IndexToOddConverter x:Key="rowIndexConverter" />
       
         <Style x:Key="alternatingDataRowStyle"
                TargetType="{x:Type xcdg:DataRow}">
            <Style.Triggers>
               <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},
                                 Path=(xcdg:DataGridVirtualizingPanel.ItemIndex),
                                 Converter={StaticResource rowIndexConverter}}"
                            Value="True">
                  <Setter Property="Background"
                          Value="AliceBlue" />
               </DataTrigger>
            </Style.Triggers>
         </Style>
     
      </Grid.Resources>
      <xcdg:DataGridControl x:Name="EmployeesGrid"
                          ItemsSource="{Binding Source={StaticResource cvs_employees}}"
                          ItemsSourceName="Employee Information"
                          AutoCreateDetailConfigurations="True">
        <xcdg:DataGridControl.DefaultDetailConfiguration>
           <xcdg:DefaultDetailConfiguration UseDefaultHeadersFooters="False"
                                            ItemContainerStyle="{StaticResource alternatingDataRowStyle}"
                                            xcdg:TableView.ShowFixedColumnSplitter="False">
              <xcdg:DefaultDetailConfiguration.DefaultGroupConfiguration>
                 <xcdg:GroupConfiguration InitiallyExpanded="False" />
              </xcdg:DefaultDetailConfiguration.DefaultGroupConfiguration>
              <xcdg:DefaultDetailConfiguration.Headers>
                 <DataTemplate>
                    <DockPanel>
                       <xcdg:HierarchicalGroupLevelIndicatorPane  xcdg:GroupLevelIndicatorPane.ShowIndicators="False"
                                                                  xcdg:TableView.CanScrollHorizontally="False"
                                                                  DockPanel.Dock="Left" />
                       <ContentPresenter Content="{Binding RelativeSource={RelativeSource Self},
                                         Path=(xcdg:DataGridControl.DataGridContext).SourceDetailConfiguration.Title}"
                                 ContentTemplate="{Binding RelativeSource={RelativeSource Self},
                                 Path=(xcdg:DataGridControl.DataGridContext).SourceDetailConfiguration.TitleTemplate}" />
                    </DockPanel>
                 </DataTemplate>
                 <DataTemplate>
                    <xcdg:ColumnManagerRow AllowColumnReorder="False"
                                           AllowSort="False" />
                 </DataTemplate>
              </xcdg:DefaultDetailConfiguration.Headers>
              <xcdg:DefaultDetailConfiguration.Footers>
                 <DataTemplate>
                    <xcdg:InsertionRow Background="Cornsilk" />
                 </DataTemplate>
              </xcdg:DefaultDetailConfiguration.Footers>
              <xcdg:DefaultDetailConfiguration.DetailIndicatorStyle>
                 <Style TargetType="{x:Type xcdg:DetailIndicator}">
                    <Setter Property="Background"
                            Value="AliceBlue" />
                 </Style>
              </xcdg:DefaultDetailConfiguration.DetailIndicatorStyle>
           </xcdg:DefaultDetailConfiguration>
        </xcdg:DataGridControl.DefaultDetailConfiguration>
     </xcdg:DataGridControl>
    </Grid>
    <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 );
     }     
    }
    Inheritance Hierarchy

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             Xceed.Wpf.DataGrid.DataGridContext

    Public Properties
     NameDescription
    Public PropertyGets a value indicating whether the end user can toggle the expansion state of details in the context.  
    Public PropertyGets a dictionary that contains a list of the context's DataGridItemProperty objects with their corresponding auto-filter values.  
    Public PropertyGets a collection of the columns whose titles are displayed in the column-chooser context menu.  
    Public PropertyGets a list of the columns contained in the context.  
    Public PropertyGets or sets the context's current column.  
    Public PropertyGets or sets the context's current data item.  
    Public PropertyGets or sets the index of the context's current data item.  
    Public PropertyGets the context's parent DataGridControl.  
    Public PropertyGets the default configuration that will be used by any groups in the context for which an explicit group configuration is not provided.  
    Public Property (Inherited from System.Windows.DependencyObject)
    Public PropertyGets a list of the configurations that will be applied to their corresponding details.  
    Public Property (Inherited from System.Windows.Threading.DispatcherObject)
    Public PropertyGets a dictionary that contains a list of the context's DataGridItemProperty objects with their corresponding distinct values.  
    Public PropertyGets a collection that contains the items that are located in the footer section of the context.  
    Public PropertyGets a group-configuration selector that will be used to select the appropriate configuration for a group in the context based on its information and/or content.  
    Public PropertyGets a collection of GroupLevelDescription objects that contain information on each group level contained in the context.  
    Public PropertyGets a value indicating whether the context has details.  
    Public PropertyGets a collection that contains the items that are located in the header section of the context.  
    Public PropertyGets a value indicating whether the context is current.  
    Public Property (Inherited from System.Windows.DependencyObject)
    Public PropertyGets the style that is applied to the container element (DataRow) generated for each item in the context.  
    Public PropertyGets a style selector that selects the appropriate style to apply to each generated container element (DataRow) in the context.  
    Public PropertyGets the collection view that was used to generate the content of the context.  
    Public PropertyGets a value indicating the maximum number of group levels that can be created.  
    Public Property
    Gets a value indicating the maximum number of sort levels that can be created.  
    Public PropertyGets a list of the merged column headers in the context.  
    Public PropertyGets the context's parent DataGridContext.  
    Public PropertyGets the parent data item to which the context belongs  
    Public PropertyGets the cell ranges selected in the data context.  
    Public PropertyGets the data item ranges selected in the data context.  
    Public PropertyGets a collection of data items that are currently selected in the context.  
    Public PropertyGets the detail configuration that was applied to the detail that is the source of the context.  
    Public PropertyGets the collection of StatCellConfiguration for a DataGridContext (that is a Detail or a Master).  
    Public PropertyGets a list of the columns in the context whose Visible property is true, ordered according to their VisiblePosition.  
    Top
    Public Methods
     NameDescription
    Public MethodRetrieves a value indicating whether the details for the specified data item are expanded.  
    Public MethodOverloaded. Places the context's current item in edit mode.  
    Public MethodCancels the edit process of the item that is being edited.  
    Public MethodOverloaded.  (Inherited from System.Windows.DependencyObject)
    Public Method (Inherited from System.Windows.DependencyObject)
    Public MethodCollapses the details owned by the specified data item.  
    Public MethodCollapses the specified group.  
    Public Method

    Enters a defer cycle that can be used to merge column reordering and visibility changes and delay automatic refresh.

     
    Public MethodEnds the edit process of the item that is being edited.  
    Public Method (Inherited from System.Windows.DependencyObject)
    Public MethodExpands any details owned by the specified data item.  
    Public MethodExpands the specified group.  
    Public MethodOverloaded. Retrieves the child DataGridContext created from the specified DetailConfiguration of an item.  
    Public MethodRetrieves the child DataGridContexts of the context.  
    Public MethodRetrieves the container of the specified item.  
    Public MethodRetrieves the group for the specified CollectionViewGroup.  
    Public Method (Inherited from System.Windows.DependencyObject)
    Public MethodRetrieves an item for the specified container.  
    Public Method (Inherited from System.Windows.DependencyObject)
    Public MethodRetrieves the parent group for the specified item.  
    Public Method (Inherited from System.Windows.DependencyObject)
    Public Method (Inherited from System.Windows.DependencyObject)
    Public MethodRetrieves a value indicating whether the specified group is expanded.  
    Public MethodMoves the first column immediately after the second.  
    Public MethodMoves the first column immediately before the second.  
    Public MethodMoves the specified current column under the specified parent column.  
    Public Method (Inherited from System.Windows.DependencyObject)
    Public Method (Inherited from System.Windows.DependencyObject)
    Public MethodOverloaded.  (Inherited from System.Windows.DependencyObject)
    Public MethodToggles any details owned by the specified data item.  
    Public MethodToggles the specified group.  
    Top
    Protected Methods
     NameDescription
    Protected MethodOverridden.   
    Protected Internal Method (Inherited from System.Windows.DependencyObject)
    Top
    Extension Methods
     NameDescription
    Public Extension MethodOverloaded. 
    Top
    Public Events
     NameDescription
    Public EventRaised when the value of a property is changed.  
    Top
    Requirements

    See Also