Xceed Toolkit Plus for WPF v5.1 Documentation
Xceed.Wpf.DataGrid.Toolkit Assembly / Xceed.Wpf.DataGrid Namespace / GroupHeaderFooterItem Structure
Members Example


In This Topic
    GroupHeaderFooterItem Structure
    In This Topic
    Structure that represents a container created from a template in the header or footer sections of a group.
    Syntax
    'Declaration
     
    Public Structure GroupHeaderFooterItem 
       Inherits System.ValueType
    'Usage
     
    Dim instance As GroupHeaderFooterItem
    public struct GroupHeaderFooterItem : System.ValueType 
    Example
    All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
    The following example demonstrates how to select all the data items contained in a group by adding them to a grid's selected-items collection when a group-header control is pressed. In the case where a group contains child groups, all the data items in the child groups will also be selected.
    <Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
        <Grid.Resources>
          <xcdg:DataGridCollectionViewSource x:Key="cvs_orders"
                                        Source="{Binding Source={x:Static Application.Current},
                                                            Path=Orders}">
            <xcdg:DataGridCollectionViewSource.GroupDescriptions>
              <xcdg:DataGridGroupDescription PropertyName="ShipCountry"/>
              <xcdg:DataGridGroupDescription PropertyName="ShipCity"/>
            </xcdg:DataGridCollectionViewSource.GroupDescriptions>
          </xcdg:DataGridCollectionViewSource>
         <Style TargetType="{x:Type xcdg:GroupHeaderControl}">
           <EventSetter Event="PreviewMouseLeftButtonDown"
                        Handler="SelectRows"/>
         </Style>
        </Grid.Resources>
        <xcdg:DataGridControl x:Name="OrdersGrid"
                            ItemsSource="{Binding Source={StaticResource cvs_orders}}"/>
      </Grid>
    Private Sub SelectRows( ByVal sender As Object, ByVal e As MouseEventArgs )
      Dim groupHeaderControl As GroupHeaderControl = TryCast( sender, GroupHeaderControl );
    
      If groupHeaderControl Is Nothing Then
        Return;
      End If
      Dim context As DataGridContext = DataGridControl.GetDataGridContext( groupHeaderControl )
    
      Dim header As GroupHeaderFooterItem = TryCast( context.GetItemFromContainer( grouHeaderControl, GroupHeaderFooterItem )
    
      If Not header.Equals( GroupHeaderFooterItem.Empty ) Then
    
        Dim group As CollectionViewGroup = context.GetParentGroupFromItem( header )
    
        If Not group Is Nothing Then
          For Each item As Object In group.Items
    
            If Typeof item Is CollectionViewGroup Then
              Me.SelectRecurse( context, CType( item, CollectionViewGroup ) )
            Else
              context.SelectedItems.Add( item )
            End If
          Next item
        End If
      End If
    End Sub
    
    Private Sub SelectRecurse( ByVal context As DataGridContext, ByVal group As CollectionViewGroup )
      For Each item As Object In group.Items
    
        If Typeof item Is CollectionViewGroup Then
          Me.SelectRecurse( context, CType( item, CollectionViewGroup ) )
        Else
          context.SelectedItems.Add( item )
        End If
      Next item
    End Sub
    private void SelectRows( object sender, MouseEventArgs e )
    {
     GroupHeaderControl groupHeaderControl = sender as GroupHeaderControl;
     if( groupHeaderControl == null )
       return;
     DataGridContext context = DataGridControl.GetDataGridContext( groupHeaderControl );
     GroupHeaderFooterItem header = ( GroupHeaderFooterItem )context.GetItemFromContainer( groupHeaderControl );
     if( !header.Equals( GroupHeaderFooterItem.Empty ) )
     {
       CollectionViewGroup group = context.GetParentGroupFromItem( header );
    
       if( group != null )
       {
         foreach( object item in group.Items )
         {
           if( item is CollectionViewGroup )
           {
             this.SelectRecurse( context, ( CollectionViewGroup )item );
           }
           else
           {
             context.SelectedItems.Add( item );
           }
         }
       }
     }
    }
    private void SelectRecurse( DataGridContext context, CollectionViewGroup group )
    {
     foreach( object item in group.Items )
     {
       if( item is CollectionViewGroup )
       {
         this.SelectRecurse( context, ( CollectionViewGroup )item );
       }
       else
       {
         context.SelectedItems.Add( item );
       }
     }
    }
    Language Filtered Section CS
    Inheritance Hierarchy

    System.Object
       System.ValueType
          Xceed.Wpf.DataGrid.GroupHeaderFooterItem

    Public Constructors
    Public Fields
     NameDescription
    Public Fieldstatic (Shared in Visual Basic)Retrieves an empty GroupHeaderFooterItem structure.  
    Top
    Public Properties
     NameDescription
    Public PropertyRetrieves the group to which the item belongs.  
    Public PropertyRetrieves the template that was used to create the item.  
    Top
    Public Methods
     NameDescription
    Public Methodstatic (Shared in Visual Basic)Overloaded. Indicates whether the GroupHeaderFooterItem instances are equal.  
    Public MethodReturns the hash code for the current instance.  
    Top
    Public Operators
    Tests if the two GroupHeaderFooterItem instances are equivalent.
    Tests if the two GroupHeaderFooterItem instances are different.
    Top
    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