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

Blazor: Conditionally display RenderFragment component

$
0
0

I've designed a simple blazor component which is a wrapper for a card. The usage looks like this:

<Card Title="Some title"><CardBody>My body content</CardBody><CardFooter><a href="...">Go</a></CardFooter></Card>

It's pretty straightforward to use. However, in some cases, I do not wish to use the CardFooter component. But I cannot conditionally choose to render CardFooter. The If statement cannot be outside like this:

@if(myCondition){<CardFooter><a href="...">Go</a></CardFooter>};

It must be inside like this:

<CardFooter>@if(myCondition){...display something};</CardFooter>

The problem is I have to render an empty CardFooter regardless. I wish I could use the IF statement to decide not to render the footer at all. Is it possible?

Thanks!


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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