Gets or sets DataTemplate for group rows.

Namespace: Dapfor.Wpf.Controls
Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)

Syntax

C#
public DataTemplate TemplateGroupRow { get; set; }
Visual Basic
Public Property TemplateGroupRow As DataTemplate
	Get
	Set
Visual C++
public:
property DataTemplate^ TemplateGroupRow {
	DataTemplate^ get ();
	void set (DataTemplate^ value);
}
F#
member TemplateGroupRow : DataTemplate with get, set

Property Value

Type: DataTemplate
DataTemplate for group rows.

Remarks

GridControl enables multiple data grouping in headers of the GridControl by any columns at any hierarchical level. When data is grouped by a specific column, GridControl searches all rows within a group that has similar values. When a group is organized, a row that doesn't contain a data object is added to the data grid. The Row.IsGroup property of such row will always return true, and Row["column id"].Value will return a value by which data is grouped. All rows with values that meet grouping conditions are attached to the newly created group. Before a new data object is added, GridControl verifies whether there is any group with the required value on the current hierarchical level. If there is no such group, a new group is created. When the Row.Update() method is invoked, the grid checks whether a row conforms to group value. If there are no more rows in the group, the group is removed from the grid.

In programming the grouping feature can be enabled via the Column.Grouped property. Sequential invocation of this property for several columns results in data grouping of these columns. The column with grouping remains visible unless Column.Visible property is set to false. Sorting (and multiple sorting) can be enabled or disabled for grouped columns because sorting and grouping are completely independent processes. The list of grouped columns can be viewed with Header.GroupedColumns collection property. A user can also group columns in the data grid. To use this ability the user just needs to drag a column to a special panel on the grid's header. However, this is not possible if height of this panel is set to 0.

DataTemplate declaration for group rows in XAML code:

 Copy imageCopy
<!-- Declare resources -->
<Window.Resources>
    <!-- Use a custom ControlTemplate for the 'Department' column -->
    <BitmapImage x:Key="Image" UriSource="/Images/dapfor.ico" DecodePixelWidth="16" DecodePixelHeight="16" />
    <DataTemplate x:Key="ColumnTemplate">
        <StackPanel Orientation="Horizontal" Height="16" HorizontalAlignment="Center">
            <Image Source="{StaticResource Image}"/>
            <TextBlock x:Name="columnText" Text="{Binding Path=Title}" Margin="4,0,4,0" />
            <Image Source="{StaticResource Image}"/>
        </StackPanel>
    </DataTemplate>

    <!-- Use a custom DataTemplate for the group rows -->
    <DataTemplate x:Key="GroupRowTemplate">
        <StackPanel Orientation="Horizontal" Height="16" HorizontalAlignment="Stretch" Background="Orange">
            <Image Source="{StaticResource Image}" Margin="4, 0, 4, 0"/>
            <TextBlock Text="{Binding Path=GroupValue}"/>
        </StackPanel>
    </DataTemplate>
</Window.Resources>

 <!-- Create a GridControl -->
<df:GridControl x:Name="grid" TemplateGroupRow="{StaticResource GroupRowTemplate}">
    <df:GridControl.Headers>
        <df:Header ScrollType="Stretch" VisibleGroupPanel="True" >
            <df:Header.Columns>
                <df:Column Id="Name" Title="Name" Width="100" />
                <df:Column Id="Department" Title="Department" Width="100" />
                <df:Column Id="Position" Title="Position" Width="100" />
            </df:Header.Columns>
        </df:Header>
    </df:GridControl.Headers>
</df:GridControl>

See Also