Explain RenderFragment and RenderFragment<T>. How do you create a templated component?
Last updated
RenderFragmentis a delegate representing a chunk of UI with no input. Default child content is aRenderFragmentnamedChildContent.RenderFragment<T>takes a value of typeTand returns markup, exposing it to the caller as@context(or a namedContext).For a templated component, declare
@typeparamand[Parameter]fragments, then invoke the template per data item, passing the item as context.
- https://learn.microsoft.com/en-us/aspnet/core/blazor/components/templated-components?view=aspnetcore-10.0
- https://www.telerik.com/blogs/blazor-basics-templating-components-renderfragments
- https://medium.com/dotnet-new/advanced-blazor-component-techniques-for-clean-scalable-ui-development-7e8f03dd3e89
- https://blazor-university.com/templating-components-with-renderfragements/
- https://www.telerik.com/blogs/blazor-components-definitive-guide
- https://blazor-university.com/templating-components-with-renderfragements/passing-placeholders-to-renderfragments/