Glossary Item Box
The xamDataPresenter™ control supports both simple and complex arrangements of cells within a record. The arrangements can be either specified manually (i.e., explicitly) or generated automatically ("AutoArrange"). The AutoArrange feature is enabled by setting the FieldLayoutSettings' AutoArrangeCells property to either LeftToRight or TopToBottom. Setting this property to Never disables the AutoArrange feature.
The AutoArrange feature is controlled by properties on FieldLayoutSettings that begin with the prefix "AutoArrange". The properties are:
The example XAML below illustrates how to use the AutoArrange feature:
<igDP:XamDataGrid>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings
AutoArrangeCells="LeftToRight"
AutoArrangeMaxColumns="4"
AutoArrangeMaxRows="3"
AutoArrangePrimaryFieldReservation="ReserveFirstRow"/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="team" IsPrimary="True"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
After the primary field reservation is taken care of, if AutoArrangeCells resolves to TopToBottom, each field is assigned a row number that is one higher than the previous field (the order is determined by the order of the fields in the Fields collection). When the AutoArrangeMaxRows is reached, the row number is reset and the column number is incremented. This process repeats until AutoArrangeMaxColumns is reached. This effectively lays out the cells in a "snaking" pattern. Of course, if AutoArrangeCells resolves to LeftToRight, the column numbers are incremented before the row numbers, which creates a different snaking pattern.
If the FieldLayoutSettings' AutoArrangeCells property is set to Never, the AutoArrange feature is disabled, and each field's cell positions must be specified manually. By default, each Field's cells will occupy the 0/0 row/column slot inside the cell area. When there are multiple fields, having all the cells stacked on top of each other is probably not what is desired. Fortunately, the Field exposes Column, ColumnSpan, Row, and RowSpan properties that let you position the cells any way you like.
The following example code defines the cell arrangement illustrated in the image below the code:
<igDP:XamDataGrid>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings
AutoArrangeCells="Never"/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="ProductName" ColumnSpan="2"/>
<igDP:Field Name="CostPerUnit" Row="1"/>
<igDP:Field Name="Quantity" Row="1" Column="1"/>
<igDP:Field Name="ShipAndHandle" Row="2"/>
<igDP:Field Name="Discount" Row="2" Column="1"/>
<igDP:Field Name="Total" Row="3" ColumnSpan="2"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
The DataPresenterBase class exposes a defaultable Boolean AutoFit property. If AutoFit is not set, the view supplies an appropriate default value. For example, the Grid view defaults to False, while the Carousel view defaults to True.
The following example code shows how the AutoFit property is set in XAML:
<igDP:XamDataGrid AutoFit="True"/>
For views such as the Grid view, all the records are constrained in one dimension based on its Orientation. For example, when the Orientation property is set to Vertical, all RecordPresenters' widths are set to fit exactly within the control, so there will never be a horizontal scroll bar. Likewise, if the Orientation property is set to Horizontal, the heights are set to fit exactly within the control so there will never be a vertical scroll bar.
For more exotic layouts, the following properties are exposed off the FieldLayoutSettings class:
Below is example XAML, illustrating how to do advanced cell layout:
<igDP:XamDataGrid>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings>
<igDP:FieldLayoutSettings.DefaultColumnDefinition>
<ColumnDefinition Width="200"/>
</igDP:FieldLayoutSettings.DefaultColumnDefinition>
</igDP:FieldLayoutSettings>
</igDP:XamDataGrid.FieldLayoutSettings>
</igDP:XamDataGrid>