Getting started with Blazor’s RenderFragment


This component emits the fragment defined by the ChildContent parameter.

Parent component using the component above

Note the two ways to use RenderFragmentExample1. In the first use, the implicit context is provided with code>@ChildContent</code as a bound field (ie, not as a tag). The code>@ChildContent</code value works only for components with a single RenderFragment parameter.

The second example is more explicit, using ChildContent as a tag with a Context attribute. Defining fragment parameters this way is required for components with more than one RenderFragment parameter (and to my eyes makes more sense).

Leave a Comment

Your email address will not be published. Required fields are marked *