wpf-devexpress-dot-xpf-dot-grid-dot-datacontrolbase-9f5022a1.md
Gets or sets the band template selector. This is a dependency property.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public DataTemplateSelector BandGeneratorTemplateSelector { get; set; }
Public Property BandGeneratorTemplateSelector As DataTemplateSelector
| Type | Description |
|---|---|
| DataTemplateSelector |
A band template selector.
|
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 and specify a data template that generates bands.
Assign the band collection to the BandsSource property and the band template to the DataControlBase.BandGeneratorTemplate property.
If you have multiple band templates, implement custom logic to choose a template:
<Window.Resources>
<!-- ... -->
<local:BandTemplateSelector x:Key="BandTemplateSelector"
MultiColumnBandTemplate="{StaticResource MultiColumnBandTemplate}"
SingleColumnBandTemplate="{StaticResource SingleColumnBandTemplate}"/>
</Window.Resources>
<dxg:GridControl ...
BandsSource="{Binding Bands}"
BandGeneratorTemplateSelector="{StaticResource BandTemplateSelector}"/>
public class BandTemplateSelector : DataTemplateSelector {
public DataTemplate SingleColumnBandTemplate { get; set; }
public DataTemplate MultiColumnBandTemplate { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container) {
Band band = item as Band;
if(band == null) return null;
if(band.Header == "Position") {
return SingleColumnBandTemplate;
}
return MultiColumnBandTemplate;
}
}
Public Class BandTemplateSelector
Inherits DataTemplateSelector
Public Property SingleColumnBandTemplate As DataTemplate
Public Property MultiColumnBandTemplate As DataTemplate
Public Overrides Function SelectTemplate(ByVal item As Object, ByVal container As DependencyObject) As DataTemplate
Dim band As Band = TryCast(item, Band)
If band Is Nothing Then Return Nothing
If band.Header = "Position" Then
Return SingleColumnBandTemplate
End If
Return MultiColumnBandTemplate
End Function
End Class
If you specify both the DataControlBase.BandGeneratorTemplate and BandGeneratorTemplateSelector , the GridControl uses the template the template selector returns.
Refer to the following help topic for more information: How to: Bind the Grid to Bands Specified in ViewModel.
See Also