Back to Devexpress

DxPopupBase.BodyTemplate Property

blazor-devexpress-dot-blazor-dot-dxpopupbase-d6ab8389.md

latest4.4 KB
Original Source

DxPopupBase.BodyTemplate Property

Specifies a template for the pop-up window’s body. Replaces the default render fragment (including paddings, scrollbars, etc.)

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public RenderFragment<IPopupElementInfo> BodyTemplate { get; set; }

Property Value

TypeDescription
RenderFragment<IPopupElementInfo>

The body template.

|

Remarks

Use the BodyTemplate property to display any render fragment in the pop-up window’s body element. This template changes the default body element rendering, including paddings, scrollbar, and inner content alignment. If you need to place custom content in the pop-up window’s body element but retain the default rendering of UI elements in it, use the BodyContentTemplate instead.

The template accepts an IPopupElementInfo object as the context parameter. You can use the parameter’s CloseCallback property to implement the Close button.

Implement two-way binding for the Visible property to show the Popup in code and update the property value when a user closes the Popup.

razor
<div @onclick="@(() => PopupVisible = true)">
    <p>CLICK TO SHOW A POP-UP WINDOW</p>
</div>

<DxPopup @bind-Visible="@PopupVisible"
         HeaderText="Edit Contact"
         ShowFooter="true">
    <BodyTemplate Context="PopupContext">
        <div class="form-container>
            <DxFormLayout>
                <DxFormLayoutItem Caption="Contact Name:" ColSpanMd="12">
                    <Template>
                        <DxTextBox Text="Nancy Davolio" />
                    </Template>
                </DxFormLayoutItem>
                <DxFormLayoutItem Caption="Birth Date:" ColSpanMd="12">
                    <Template>
                        <DxDateEdit Date="DateTime.Now.AddYears(-30)" />
                    </Template>
                </DxFormLayoutItem>
                <DxFormLayoutItem Caption="Years Worked:" ColSpanMd="12">
                    <Template>
                        <DxSpinEdit Value="3" />
                    </Template>
                </DxFormLayoutItem>
                <DxFormLayoutItem Caption="Email:" ColSpanMd="12">
                    <Template>
                        <DxTextBox Text="[email protected]" />
                    </Template>
                </DxFormLayoutItem>
            </DxFormLayout>
        </div>
    </BodyTemplate>
    <FooterContentTemplate>
        <DxButton RenderStyle="ButtonRenderStyle.Primary" Text="OK"
                  Click="@context.CloseCallback" />
    </FooterContentTemplate>
</DxPopup>

@code {
    bool PopupVisible { get; set; } = false;
}
css
.form-container {
    padding-top: 1rem; 
    padding-bottom: 1rem;
}

Run Demo: Popup - Customization

You can also use the following properties to customize the body:

  • BodyText - Allows you display plain text and applies all predefined appearance settings.
  • BodyContentTemplate - Allows you to customize the body’s content area and applies predefined content alignment and paddings.

The BodyTemplate property takes priority over the BodyText and BodyContentTemplate properties.

For additional information about Popup customization, refer to the following help topic: Content and Appearance.

See Also

DxPopupBase Class

DxPopupBase Members

DevExpress.Blazor Namespace