Back to Devexpress

DxButtonBase.ChildContent Property

blazor-devexpress-dot-blazor-dot-dxbuttonbase-f6e0b8ae.md

latest2.6 KB
Original Source

DxButtonBase.ChildContent Property

Specifies Button content.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

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

Property Value

TypeDescription
RenderFragment<RenderFragment>

Content markup.

|

Remarks

The ChildContent component parameter can store custom component content that does not belong to other component’s RenderFragment properties as shown below:

razor
<DxButton RenderStyle="ButtonRenderStyle.Info"
          Click="@Like"
          IconCssClass="btn-icon-like"
          Text="Like">
    <ChildContent>
            @context
            <span class="ms-1">@likes</span>
    <ChildContent>
</DxButton>
@* ... *@
@code {
    int likes;

    void Like(MouseEventArgs args) {
        likes++;
    }
    protected override void OnInitialized() {
        likes = 1;
    }
}

In this example, the Button renders custom content (like counter) next to the default content specified in the button’s properties (text and icon). Use the @context parameter to specify where the default content should be rendered.

Note

Buttons are rendered as a button HTML element. According to HTML specification a button must not contain interactive elements or elements with the tabindex attribute specified.

You can omit the <ChildContent> tag and specify the markup directly in the <DxButton> tag:

razor
<DxButton RenderStyle="ButtonRenderStyle.Info"
              Click="@Like"
              IconCssClass="btn-icon btn-icon-like"
              @* ... *@
              Text="Like">
        @context
        <span class="ms-1">@likes</span>
    </DxButton>
    @* ... *@
@code {
    int likes;

    void Like(MouseEventArgs args) {
        likes++;
    }
    protected override void OnInitialized() {
        likes = 1;
    }
}

Run Demo: Button — Custom Content

See Also

DxButtonBase Class

DxButtonBase Members

DevExpress.Blazor Namespace