Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Use Blazor Component Template with RenderFragment without additional Tags

$
0
0

I am currently experimenting with templated components in Blazor. I am trying to set up a component with a RenderFragment parameter.

For example:

<div>    @this.Content</div>@code {    [Parameter]    public RenderFragment? Content { get; set; }}

When I use it on a Razor page, it looks like this:

<MyComponent><Content></Content></MyComponent>

I'd prefer not having to add the <Content> tag every time, but have everything inside the component brackets be the content.

Is there a way to achieve my preferred behavior?

I looked up different ways to pass parameters to a component, but I haven't quite figured out how to remove the need for the additional tags.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>