Reputation: 21062
I have base component with basic html content and derived component which adds decorations to it. But now I realized I don't know how to make blazor put base content within derived component. I am looking in my case for something like this:
<div>
<span>my derived decoration</span>
@base_content
</div>
How to tell Blazor to put "here" the base content?
Upvotes: 1
Views: 434
Reputation: 5476
There's a Github post where a user is complaining the using the __builder field is "hacky" because its an internal field... the following was suggested which works as well and definitely looks better:
@((RenderFragment)base.BuildRenderTree)
Source: https://github.com/dotnet/aspnetcore/issues/47538
Upvotes: 2
Reputation: 23234
In your derived components .razor
file include a call to base.BuildRenderTree(__builder)
.
An example:
@inherits YourBaseComponent
<div>
<span>my derived decoration</span>
@{
base.BuildRenderTree(__builder);
}
</div>
Upvotes: 3