DxFormLayoutItemBase.Template Property

Specifies a template used to display the layout item.

Namespace: DevExpress.Blazor.Base

Assembly: DevExpress.Blazor.dll


public RenderFragment<object> Template { get; set; }

Property Value

Type Description

The template content.


The Template property allows you to provide a custom editor for the layout item.

    <DxFormLayoutItem Caption="Contact Name:" >
            <DxTextBox @bind-Text="@Name"></DxTextBox>

    <DxFormLayoutItem Caption="Email:" >
            <DxTextBox @bind-Text="@Email"></DxTextBox>

In data-bound mode, each layout item automatically displays a DevExpress data editor suitable for the target data type.


Item templates should not include layout hierarchy objects (groups, items). Otherwise, an exception occurs.

When you use a Form Layout item's template, the component is not notified when a user changes data within an item's custom editor. To inform the Form Layout about the change, call the OnChanged(Object) method when a custom editor's value is changed. To access a custom editor's new value, use the Value property.

<DxFormLayout Data="@editFormData"
              ItemUpdating="@((fieldName, newValue) => OnItemUpdating(fieldName, newValue))">
    <DxFormLayoutItem Field="@nameof(FormDataItem.Position)" Caption="Position:" ColSpanMd="6">
            <DxComboBox Data="@(new List<string>() { "Sales Representative", "Designer" })"
                        SelectedItemChanged="@(value => ((ValueEditContext)context).OnChanged(value))">

@code {
    FormDataItem editFormData = new FormDataItem() {
        Name = "Nancy Davolio",
        BirthDate = DateTime.Now.AddYears(-30),
        YearsWorked = 3,
        Position = "Sales Representative"

    void OnItemUpdating(string fieldName, object newValue) {
        if (fieldName == nameof(FormDataItem.Name)) {
            editFormData.Name = newValue.ToString();
        } else if (fieldName == nameof(FormDataItem.BirthDate)) {
            editFormData.BirthDate = (DateTime)newValue;
        } else if (fieldName == nameof(FormDataItem.YearsWorked)) {
            editFormData.YearsWorked = (int)newValue;
        } else if (fieldName == nameof(FormDataItem.Position)) {
            editFormData.Position = newValue.ToString();



Online Demo: Form Layout - Data Binding

See Also