HowTo : Common headers in the XamDataGrid

John Doe / Wednesday, June 2, 2010


1. Set the AutoGenerateFields and AutoArrangeCells properties of the FieldLayoutSettings to respectively False and Never:

                <igDP:FieldLayoutSettings AutoGenerateFields="False" AutoArrangeCells="Never" />

2. Define the FieldLayout and explicitly position each field, by setting the Row, RowSpan, Column, ColumnSpan properties :

                    <igDP:UnboundField Name="Header" Label="Person" Row="0" Column="0" ColumnSpan="6">
                            <igDP:FieldSettings LabelTextAlignment="Center" CellContentAlignment="LabelOnly"/>
                    <igDP:Field Name="FirstName" Label="First Name" Row="1" Column="0"/>
                    <igDP:Field Name="LastName" Label="Last Name" Row="1" Column="1" />
                    <igDP:Field Name="Email" Row="1" Column="2" />
                    <igDP:Field Name="Age" Row="1" Column="3" />
                    <igDP:Field Name="BirthDay" Row="1" Column="4" />
                    <igDP:Field Name="Gender" Row="1" Column="5" />
                    <igDP:Field Name="Interests" />

3. Set the CellContentAlignment to LabelOnly as this Field has only header representation purposes.

The goal:

The result:

The working sample :