Skip to main content

ColumnBase.CellEditTemplate Property

Gets or sets a template that displays a custom editor used to edit column values. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

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

NuGet Package: DevExpress.Wpf.Grid.Core


public DataTemplate CellEditTemplate { get; set; }

Property Value

Type Description

A template that displays a custom editor.


The binding source for the CellEditTemplate is EditGridCellData. Refer to the Data Binding section.


The immediate posting functionality is not supported when the Data Grid uses the CellEditTemplate.

To apply different cell templates based on certain conditions, use a custom CellEditTemplateSelector. If both the CellEditTemplate and CellEditTemplateSelector are specified, the template returned by the template selector has a higher priority. If the template selector returns null, the template specified by the CellEditTemplate property is used.

Each column has the following templates that define editors for display and edit modes:

Template Description
ColumnBase.CellDisplayTemplate / DataViewBase.CellDisplayTemplate Defines a template that displays column values.
ColumnBase.CellEditTemplate / DataViewBase.CellEditTemplate Defines a template that represents an editor used to edit cell values.

Custom In-Place Cell Editors

We recommend that you set a custom editor in the cell template as follows:

  • The editor is a BaseEdit descendant.
  • The editor’s Name property is set to PART_Editor.

This technique has the following advantages:

  • Binds the editor’s value to the source field specified by the ColumnBase.FieldName or ColumnBase.Binding properties.
  • Full keyboard navigation.
  • Input validation support. For more information, refer to the Input Validation topic.
  • Removes the editor’s border to adjust the appearance of in-place use.

In the following code sample, a numeric column uses the ProgressBarEdit editors to display data. When users focus cells, the TrackBarEdit editors replace progress bars:

    <!-- ... -->
    <dxg:GridColumn FieldName="UnitsOnOrder">
                <dxe:ProgressBarEdit Name="PART_Editor" Minimum="0" Maximum="50" />
                <dxe:TrackBarEdit Name="PART_Editor" Minimum="0" Maximum="50" />
    <!-- ... -->   

To change how the GridControl binds the cell editor to a source property, use the ColumnBase.Binding property:

<dxg:GridColumn Header="Name" 
    Binding="{Binding Name, Mode=TwoWay,
        Converter={StaticResource myConverter}}" >
            <dxe:TextEdit Name="PART_Editor" IsEnabled="{Binding RowData.Row.Enabled}" />  

Use the editor’s EditValue property if you need to change how the GridControl handles the editor’s value and specify a custom binding.

<dxg:GridColumn FieldName="Name">
            <!--DataContext is EditGridCellData-->
            <dxe:TextEdit Name="PART_Editor" EditValue="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource myConverter}}"/>  
            <dxe:TextEdit Name="PART_Editor" EditValue="{Binding RowData.Row.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource myConverter}}"/>-->
            <!--RowData.Row is a path to an underlying row object-->

Non-DevExpress Editors

View Example: How to Use Custom Editors to Edit Cell Values

You can use non-BaseEdit cell editors in the CellEditTemplate to edit data. This method has the following limitations:

  • You cannot sue the PART_Editor method, you should bind the editor’s value.
  • Non-DevExpress editors do not use lightweight templates that are designed to improve performance.
  • The GridControl does not remove the editor’s borders to adjust the appearance of in-place editors.
  • You need to handle events to process user actions such as focusing and keyboard navigation:
  • Input Validation is not supported.

Data Binding

Cell elements contain EditGridCellData objects in their DataContext.

Use the following binding paths to access cell values, columns, and ViewModel properties:

  • Value - access the current cell value;
  • Column - access the current column;
  • RowData.Row.[YourPropertyName] - access a property of an object from the ItemsSource collection;
  • Data.[FieldName] - access column values in Server Mode or if you use the RealTimeSource, access unbound column values;
  • View.DataContext.[YourPropertyName] - access a property in a grid’s ViewModel.

View Example: Build Binding Paths in WPF Data Grid Cells

The code sample below shows how to use a custom ComboBoxEdit within grid cells and bind its ItemsSource to a data row property:

<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;

Data Processing and EditSettings

When you use the CellEditTemplate, the editor specified in the EditSettings property is ignored. However, the EditSettings value affects the formatting settings, data processing (sorting, grouping, filtering, summary calculation), and export.

Events in CellTemplate

The GridControl utilizes virtualization to improve its performance. Virtualization reuses row, cell, and column visual elements, and changes their properties and data context.

Do not handle events related to changes in the EditValue, Text, Value, SelectedItem, and other value-related properties to avoid issues related to virtualization. Instead, use CellValueChangingEvent and CellValueChangedEvent.

Refer to this KB article for more information: How to avoid problems with the DXGrid virtualization mechanism.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CellEditTemplate property.


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