EditTemplate Property

Template used while the editor is in edit mode.
Public Property EditTemplate As ControlTemplate
public ControlTemplate EditTemplate {get; set;}

ValueEditor exposes two ControlTemplate properties: Template property which it inherits from the base Control class and the EditTemplate property. Value of Template property is used when the editor is in display mode where as the value of EditTemplate property is used when the editor is in edit mode. If EditTemplate is not specified then the editor will use the value of Template property for both edit and display mode. This means that the Template property is required however EditTemplate could be left off to null. However note that if you do so, the control template specified by the Template property must support editing as well.

As an example, XamTextEditor's Template property uses TextBlock to display the contents. Its EditTemplate uses a TextBox to display and edit contents since EditTemplate has to support editing as well. TextBlock is more efficient than TextBox and therefore this kind of configuration can result in greater rendering speeds, esp. when a lot of editor instances are to be rendered like in a XamDataGrid where each cell has an instance of ValueEditor. In a control like XamDataGrid, only one cell can be in edit mode at a time and therefore only one ValueEditor instance in the XamDataGrid will use EditTemplate at a time while the rest will use the more efficient control template provided by the Template property.

Note: The editors provide default values for Template and EditTemplate properties. You don't need to typically set these properties unless you want to change the default control templates used by an editor.

Note: When the editor enters edit mode the Template property will be set to the value of EditTemplate to apply the edit template. However since the editor needs to switch back to the origianl value of the Template property when the editor exits edit mode, the editor stores the original value of Template property so it can revert back to it when the editor exits the edit mode.


Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also