DataControlBase.BandsSource Property
Gets or sets the source from which the grid generates bands. This is a dependency property.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.Core.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Property Value
Type | Description |
---|---|
IEnumerable | The source from which the grid generates bands. |
Remarks
You can define bands in a ViewModel and display them in the GridControl. To do this, follow the steps below:
- Create a collection of grid bands in a ViewModel.
Specify a data template that generates bands:
<Window.Resources> <DataTemplate x:Key="ColumnTemplate"> <dxg:GridColumn FieldName="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}" /> </DataTemplate> <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}" /> </DataTemplate> </Window.Resources>
Assign the band collection to the BandsSource property and the band template to the DataControlBase.BandGeneratorTemplate property:
<dxg:GridControl ... BandsSource="{Binding Bands}" BandGeneratorTemplate="{StaticResource MultiColumnBandTemplate}"/>
Note
You cannot specify the BandsSource and DataControlBase.ColumnsSource properties simultaneously.
Refer to the following help topic for more information: How to: Bind the Grid to Bands Specified in ViewModel.