Skip to main content

DataControlBase.BandGeneratorTemplate Property

Gets or sets a template that describes grid bands. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v24.1.Core.dll

NuGet Package: DevExpress.Wpf.Grid.Core


public DataTemplate BandGeneratorTemplate { get; set; }

Property Value

Type Description

The band template.


You can define bands in a ViewModel and display them in the GridControl. To do this, follow the steps below:

  1. Create a collection of grid bands in a ViewModel.
  2. Specify a data template that generates bands:

        <DataTemplate x:Key="ColumnTemplate">
            <dxg:GridColumn FieldName="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}" />
        <DataTemplate x:Key="MultiColumnBandTemplate">
            <dxg:GridControlBand Header="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).Header, RelativeSource={RelativeSource Self}}" 
                                 ColumnsSource="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).ChildColumns, RelativeSource={RelativeSource Self}}" 
                                 ColumnGeneratorTemplate="{StaticResource ColumnTemplate}" />
  3. Assign the band collection to the BandsSource property and the band template to the BandGeneratorTemplate property:

    <dxg:GridControl ...
                     BandsSource="{Binding Bands}" 
                     BandGeneratorTemplate="{StaticResource MultiColumnBandTemplate}"/>

If you have multiple band templates, use the DataControlBase.BandGeneratorTemplateSelector property to specify a template selector that chooses a template based on the band type.

Refer to the following help topic for more information: How to: Bind the Grid to Bands Specified in ViewModel.

See Also