Xceed DataGrid for WPF v7.2 Documentation
MergedColumnCollection Class
Members  Example 


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace : MergedColumnCollection Class
Represents a dynamic Column collection that provides notifications when items are added or removed, or when the whole collection is refreshed.
Object Model
MergedColumnCollection ClassColumnBase Class
Syntax
'Declaration
 
<DefaultMemberAttribute("Item")>
<DebuggerTypeProxyAttribute(System.Collections.Generic.Mscorlib_CollectionDebugView`1)>
<DebuggerDisplayAttribute("Count = {Count}")>
Public Class MergedColumnCollection 
   Inherits ColumnCollection
'Usage
 
Dim instance As MergedColumnCollection
[DefaultMember("Item")]
[DebuggerTypeProxy(System.Collections.Generic.Mscorlib_CollectionDebugView`1)]
[DebuggerDisplay("Count = {Count}")]
public class MergedColumnCollection : ColumnCollection 
Remarks
Used to set the MergedColumns property.
Example

The following shows how to set up merged column headers.

<xcdg:DataGridControl x:Name="grid"
                       ItemsSource="{Binding Source={StaticResource cvsTransactions}}"
                       ReadOnly="True"
                       NavigationBehavior="RowOnly">
   <xcdg:DataGridControl.Resources>
     <!-- These implicit styles that are local to this DataGridControl are an
                  elegant way to set some desired default values of various grid elements. -->
     <ResourceDictionary>
       <Style TargetType="xcdg:MergedColumnManagerRow">
         <Setter Property="AllowColumnReorder"
                 Value="{Binding ElementName=allowMergedColumnReorderCheckBox,Path=IsChecked}"/>
         <Setter Property="AllowColumnResize"
                 Value="{Binding ElementName=allowMergedColumnResizeCheckBox,Path=IsChecked}"/>
       </Style>

       <Style TargetType="xcdg:ColumnManagerRow">
         <Setter Property="AllowColumnReorder"
                 Value="{Binding ElementName=allowColumnReorderCheckBox,Path=IsChecked}"/>
         <Setter Property="AllowColumnResize"
                 Value="{Binding ElementName=allowColumnResizeCheckBox,Path=IsChecked}"/>
       </Style>
     </ResourceDictionary>
   </xcdg:DataGridControl.Resources>

   <xcdg:DataGridControl.MergedHeaders>
     <xcdg:MergedHeader>
       <xcdg:MergedHeader.MergedColumns>
         <xcdg:MergedColumn FieldName="Quarter1"
                            Title="Quarter 1"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="JanuarySummary,FebruarySummary,MarchSummary" />
         <xcdg:MergedColumn FieldName="Quarter2"
                            Title="Quarter 2"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="AprilSummary,MaySummary,JuneSummary" />
         <xcdg:MergedColumn FieldName="Quarter3"
                            Title="Quarter 3"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="JulySummary,AugustSummary,SeptemberSummary" />
         <xcdg:MergedColumn FieldName="Quarter4"
                            Title="Quarter 4"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="OctoberSummary,NovemberSummary,DecemberSummary" />
       </xcdg:MergedHeader.MergedColumns>
     </xcdg:MergedHeader>
     <xcdg:MergedHeader>
       <xcdg:MergedHeader.MergedColumns>
         <xcdg:MergedColumn FieldName="JanuarySummary"
                            Title="January Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="JanuaryIncome,JanuaryExpense" />
         <xcdg:MergedColumn FieldName="FebruarySummary"
                            Title="February Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="FebruaryIncome,FebruaryExpense" />
         <xcdg:MergedColumn FieldName="MarchSummary"
                            Title="March Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="MarchIncome,MarchExpense" />
         <xcdg:MergedColumn FieldName="AprilSummary"
                            Title="April Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="AprilIncome,AprilExpense" />
         <xcdg:MergedColumn FieldName="MaySummary"
                            Title="May Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="MayIncome,MayExpense" />
         <xcdg:MergedColumn FieldName="JuneSummary"
                            Title="June Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="JuneIncome,JuneExpense" />
         <xcdg:MergedColumn FieldName="JulySummary"
                            Title="July Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="JulyIncome,JulyExpense" />
         <xcdg:MergedColumn FieldName="AugustSummary"
                            Title="August Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="AugustIncome,AugustExpense" />
         <xcdg:MergedColumn FieldName="SeptemberSummary"
                            Title="September Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="SeptemberIncome,SeptemberExpense" />
         <xcdg:MergedColumn FieldName="OctoberSummary"
                            Title="October Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="OctoberIncome,OctoberExpense" />
         <xcdg:MergedColumn FieldName="NovemberSummary"
                            Title="November Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="NovemberIncome,NovemberExpense" />
         <xcdg:MergedColumn FieldName="DecemberSummary"
                            Title="December Transactions"
                            CellHorizontalContentAlignment="Center"
                            ChildColumnNames="DecemberIncome,DecemberExpense" />
       </xcdg:MergedHeader.MergedColumns>
     </xcdg:MergedHeader>
   </xcdg:DataGridControl.MergedHeaders>

   <xcdg:DataGridControl.Columns>
     <xcdg:Column FieldName="JanuaryIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="JanuaryExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="FebruaryIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="FebruaryExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="MarchIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="MarchExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="AprilIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="AprilExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="MayIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="MayExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="JuneIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="JuneExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="JulyIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="JulyExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="AugustIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="AugustExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="SeptemberIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="SeptemberExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="OctoberIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="OctoberExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="NovemberIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="NovemberExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="DecemberIncome"
                  Title="Income"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

     <xcdg:Column FieldName="DecemberExpense"
                  Title="Expense"
                  CellContentTemplate="{StaticResource currencyCellDataTemplate}" />

   </xcdg:DataGridControl.Columns>

   <xcdg:DataGridControl.View>
     <!-- In this sample, you can define this resource to specify the default
                  theme this DataGridControl will be in. This is not mandatory, so we
                  use a DynamicResource to silently ignore its absence. -->
     <xcdg:TableflowView Theme="{DynamicResource defaultTheme}"
                         AllowColumnChooser="{Binding Source={x:Static local:ConfigurationData.Singleton}, Path=AllowColumnChooser}"
                         ShowFixedColumnSplitter="{Binding Source={x:Static local:ConfigurationData.Singleton}, Path=ShowFixedColumnSplitter}" />
   </xcdg:DataGridControl.View>

 </xcdg:DataGridControl>
Inheritance Hierarchy

System.Object
   System.Collections.ObjectModel.Collection<T>
      Xceed.Wpf.DataGrid.ContentElementCollection<T>
         Xceed.Wpf.DataGrid.ObservableColumnCollection
            Xceed.Wpf.DataGrid.ColumnCollection
               Xceed.Wpf.DataGrid.MergedColumnCollection

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

MergedColumnCollection Members
Xceed.Wpf.DataGrid Namespace