Skip to main content
A newer version of this page is available. .

DataControlBase.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.v18.2.Core.dll

Declaration

public DataTemplateSelector BandGeneratorTemplateSelector { get; set; }

Property Value

Type Description
DataTemplateSelector

The band template selector.

Remarks

The GridControl 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.

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)((Control)container).FindResource("SingleColumnBandTemplate");
            }
            return (DataTemplate)((Control)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 grid’s DataControlBase.BandGeneratorTemplate property.

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BandGeneratorTemplateSelector property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also