TextEditBase.EditNonEditableTemplate Property

Gets or sets a template that defines the editor's presentation when the editor's text field is not editable. This is a dependency property.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v20.1.dll

Declaration

[Browsable(false)]
public ControlTemplate EditNonEditableTemplate { get; set; }
<Browsable(False)>
Public Property EditNonEditableTemplate As ControlTemplate

Property Value

Type Description
ControlTemplate

A ControlTemplate object representing the editor's template.

Remarks

The EditNonEditableTemplate property is in effect for the ButtonEdit editor and its derived editors (such as the ComboBoxEdit).

The template, specified via the EditNonEditableTemplate property, is applied to the editor's text field when the ButtonEdit.IsTextEditable property is set to false. In this case, the editor's text field cannot be edited, and an end user can change the editor's value only by choosing a new value in editor's popup.

The EditNonEditableTemplate property is not used when the editor is in in-place inactive mode (e.g., when an editor is used in a GridControl cell and this cell is not activated).

EditNonEditableTemplate's *DataContext depends on whether the editor is standalone or in-place. In both cases, use the BaseEdit.OwnerEdit attached property to bind to editor properties, for example:

<dxe:ComboBoxEdit.EditNonEditableTemplate>
    <ControlTemplate>
        <TextBlock Text="{Binding (dxe:BaseEdit.OwnerEdit).EditValue}"/>
    </ControlTemplate>
</dxe:ComboBoxEdit.EditNonEditableTemplate>

Examples

The following example shows how to customize the in-place combo box editor's appearance when its text field is not editable. In this example, in-place combo boxes are used to edit the 'Access Card Color' column field values. The appearance of the editors' items on the drop-down list is specified via the ItemTemplate property. As for the edit box, you can either apply the same template by setting the ApplyItemTemplateToSelectedItem property to true or specify another template using the EditNonEditableTemplate property (in this example, we used the second approach).

<Window x:Class="TextEdit_EditNonEditableTemplate.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="Access Cards"
        Width="300"
        Height="200">

    <dxg:GridControl Name="gridControl1">
        <dxg:GridControl.Columns>
            <dxg:GridColumn FieldName="Name" />
            <dxg:GridColumn FieldName="CardColor" Header="Access Card Color">
                <dxg:GridColumn.EditSettings>
                    <dxe:ComboBoxEditSettings IsTextEditable="False">
                        <dxe:ComboBoxEditSettings.ItemTemplate>
                            <DataTemplate>
                                <Border Background="Transparent">
                                    <StackPanel Orientation="Horizontal">
                                        <Rectangle Width="10"
                                                   Height="10"
                                                   Margin="6,0,6,0"
                                                   Fill="{Binding TargetNullValue=Transparent}"
                                                   RadiusX="2"
                                                   RadiusY="2" />
                                        <TextBlock Text="{Binding}" />
                                    </StackPanel>
                                </Border>
                            </DataTemplate>
                        </dxe:ComboBoxEditSettings.ItemTemplate>
                        <dxe:ComboBoxEditSettings.EditNonEditableTemplate>
                            <ControlTemplate>
                                <Rectangle Margin="2"
                                           Fill="{Binding EditValue, RelativeSource={RelativeSource TemplatedParent}}"
                                           RadiusX="2"
                                           RadiusY="2" />
                            </ControlTemplate>
                        </dxe:ComboBoxEditSettings.EditNonEditableTemplate>
                        <dxe:ComboBoxEditSettings.Items>
                            <sys:String>Red</sys:String>
                            <sys:String>Green</sys:String>
                            <sys:String>Blue</sys:String>
                        </dxe:ComboBoxEditSettings.Items>
                    </dxe:ComboBoxEditSettings>
                </dxg:GridColumn.EditSettings>
            </dxg:GridColumn>
        </dxg:GridControl.Columns>
        <dxg:GridControl.View>
            <dxg:TableView AutoWidth="True" />
        </dxg:GridControl.View>
    </dxg:GridControl>

</Window>
See Also