Back to Devexpress

DataViewBase.CellEditTemplate Property

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-28a548ed.md

latest5.4 KB
Original Source

DataViewBase.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.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public DataTemplate CellEditTemplate { get; set; }
vb
Public Property CellEditTemplate As DataTemplate

Property Value

TypeDescription
DataTemplate

A template that displays a custom editor.

|

Remarks

The binding source for the CellEditTemplate template is represented by the EditGridCellData class.

In-place editors are used for both presenting data and editing records. You can use separate in-place editors for both tasks. Each column provides two templates that allow you to define custom editors that display (when the grid is in browse mode) and/or edit (when the grid is in edit mode) column values:

TemplateDescription
ColumnBase.CellDisplayTemplate / DataViewBase.CellDisplayTemplateDefines a template that displays column values.
ColumnBase.CellEditTemplate / DataViewBase.CellEditTemplateDefines a template that represents an editor used to edit cell values.

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:

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

Tip

Tip

A template that defines the presentation of data cells is specified by the CellEditTemplate 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 DataViewBase.CellEditTemplateSelector property.

If both the CellDisplayTemplate and DataViewBase.CellEditTemplateSelector 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 CellEditTemplate property is used.

See Also

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace