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

Blazor render fragment starting with expression

$
0
0

Is it possible to start a render fragment with an expression block? For example is it possible to write the Blazor render fragment below without the outer tags?

@{         RenderFragment<MyClass> myRenderFragment = (ctx) =>        @<text>                            @{var clas = ctx.Bold ? "bold" : "";}<span class="@clas">@ctx.Text</span></text>;}@myRenderFragment(new MyClass(true, "Hello"))@myRenderFragment(new MyClass(false, "World"))@code {    public record class MyClass(bool Bold, string Text);}

Viewing all articles
Browse latest Browse all 4263

Trending Articles



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