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


Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace : MergedColumn Class
Represents a merged column, in which field-level columns or other merged columns can be placed so that they can be grouped under column-spanning merged headers to better organize data visually. Multiple levels of merged headers are supported.
Syntax
'Declaration
 
<DebuggerDisplayAttribute("FieldName = {FieldName}")>

<StyleTypedPropertyAttribute(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)>

<XmlLangPropertyAttribute("Language")>

<UsableDuringInitializationAttribute(True)>

<RuntimeNamePropertyAttribute("Name")>

<TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>

<NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>

Public Class MergedColumn 

   Inherits ColumnBase
'Usage
 
Dim instance As MergedColumn
[DebuggerDisplay("FieldName = {FieldName}")]

[StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)]

[XmlLangProperty("Language")]

[UsableDuringInitialization(true)]

[RuntimeNameProperty("Name")]

[TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]

[NameScopeProperty("NameScope", System.Windows.NameScope)]

public class MergedColumn : ColumnBase 
Remarks

See the Merged Column Headers topic for more information.

Merged column headers are only supported in TableView and TableFlowView.

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.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.ContentElement
            System.Windows.FrameworkContentElement
               Xceed.Wpf.DataGrid.ColumnBase
                  Xceed.Wpf.DataGrid.MergedColumn

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

MergedColumn Members
Xceed.Wpf.DataGrid Namespace