Back to Devexpress

BandBase.BandGeneratorTemplateSelector Property

wpf-devexpress-dot-xpf-dot-grid-dot-bandbase-dcb3a18a.md

latest2.9 KB
Original Source

BandBase.BandGeneratorTemplateSelector Property

Gets or sets the data template selector which chooses a template based on the band’s settings. This is a dependency property.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public DataTemplateSelector BandGeneratorTemplateSelector { get; set; }
vb
Public Property BandGeneratorTemplateSelector As DataTemplateSelector

Property Value

TypeDescription
DataTemplateSelector

The band template selector.

|

Remarks

The GridControl and its bands can be bound to a collection of objects containing band settings, described in a Model or ViewModel. The GridControl generates bands based on band templates. Using a single template, you can create an unlimited number of bands in an unlimited number of grid controls.

To choose the required band template based on the band’s settings, use the Data Template Selector assigned to the BandGeneratorTemplateSelector property.

csharp
using System.Windows;
using System.Windows.Controls;
using Model;

namespace View {
    public class BandTemplateSelector : DataTemplateSelector {
        public override DataTemplate SelectTemplate(object item, DependencyObject container) {
            Band band = (Band)item;
            if(band.ChildColumns.Count == 1) {
                return (DataTemplate)((FrameworkElement)container).FindResource("SingleColumnBandTemplate");
            }
            return (DataTemplate)((FrameworkElement)container).FindResource("MultiColumnBandTemplate");
        }
    }
}

If all grid bands can be described using a single template, you have no need to create a band template selector. Instead, assign this template to the band’s BandBase.BandGeneratorTemplate property.

To learn more, see Binding to a Collection of Bands.

See Also

How to: Bind the Grid to Bands Specified in ViewModel

BandBase Class

BandBase Members

DevExpress.Xpf.Grid Namespace