Skip to main content

DataControlBase.ColumnGeneratorTemplateSelector Property

Gets or sets the data template selector which chooses a template based on the column's type. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

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

#Declaration

[CloneDetailMode(CloneDetailMode.Skip)]
public DataTemplateSelector ColumnGeneratorTemplateSelector { get; set; }

#Property Value

Type Description
DataTemplateSelector

The column template selector.

#Remarks

The Grid Control can be bound to a collection of objects containing column settings, described in a Model or ViewModel, minimizing the need for 'code-behind'. The Grid Control generates columns based on column templates. Create multiple templates, one template for each column type. Using a single template, you can create an unlimited number of columns in an unlimited number of grid controls.

To choose the required column template based on the column's type, use the Data Template Selector assigned to the ColumnGeneratorTemplateSelector property.


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

namespace View {
    public class ColumnTemplateSelector : DataTemplateSelector {
        public override DataTemplate SelectTemplate(object item, DependencyObject container) {
            Column column = (Column)item;
            return (DataTemplate)((Control)container).FindResource(column.Settings + "ColumnTemplate");
        }
    }
}

If all grid columns can be described using a single template, you have no need to create a column template selector. Instead, assign this template to the grid's DataControlBase.ColumnGeneratorTemplate property.

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

See Also