A newer version of this page is available. Switch to the current version.

ColumnBase.CellTemplate Property

Gets or sets the template that defines the presentation of column cells. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v19.1.Core.dll


public DataTemplate CellTemplate { get; set; }
Public Property CellTemplate As DataTemplate

Property Value

Type Description

A DataTemplate object that defines the presentation of column cells.


Use the CellTemplate property to define a template that specifies the visualization of column cells. The binding source for the CellTemplate template is represented by the EditGridCellData class.

The EditGridCellData class has the Value property that provides access to the cell editable value. Use the RowData.Row property to access a row's data object property: {Binding RowData.Row.[YourPropertyName]}

The code sample belows shows how to use a custom ComboBoxEdit within grid cells:

<dxg:GridControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" ItemsSource="{Binding Items}">
    <dxg:GridColumn FieldName="Country"/>
    <dxg:GridColumn FieldName="City">
                <dxe:ComboBoxEdit x:Name="PART_Editor" ItemsSource="{Binding RowData.Row.Cities}"/>
public ObservableCollection<CountryCities> Items {
    get {
        if(this._Items == null) {
            this._Items = new ObservableCollection<CountryCities>();

            CountryCities usa = new CountryCities() {
                Country = "USA",
                Cities = new List<string> { "Washington, D.C.", "New York", "Los Angeles", "Las Vegas" },
                City = "Los Angeles"

            CountryCities germany = new CountryCities() {
                Country = "Germany",
                Cities = new List<string> { "Berlin", "Munich", "Frankfurt" },
                City = "Munich"

            CountryCities russia = new CountryCities() {
                Country = "Russia",
                Cities = new List<string> { "Moscow", "Saint-Petersburg" },
                City = "Moscow"
        return this._Items;

A template that defines the presentation of data cells is specified by the CellTemplate property. If you have more than one template that can be used to render cells, you can implement custom logic to choose the required template. To do this, derive from the DataTemplateSelector class, implement the SelectTemplate method that returns a template which meets the required condition, and assign it to the ColumnBase.CellTemplateSelector property.

If both the CellTemplate and ColumnBase.CellTemplateSelector are specified, a cell is rendered using the template returned by the template selector. If the template selector returns null, the template specified by the CellTemplate property is used.


When using the CellTemplate, an editor specified with the ColumnBase.EditSettings property is ignored (but its formatting settings persist).


Editors specified in the CellTemplate do not affect data processing (sorting, grouping, filtering, summary calculation) and export.

Use the PrintCellStyle property to customize cell appearance when printing and exporting the GridControl's data.

The GridControl.CustomColumnDisplayText allows you to display custom text within any cell. The provided text provided is used when the grid is printed.

See Also