Is there a way to check if RenderFragment is empty?
For example, in the code below, MyComp
shows the Detail
if Open
is true & you can toggle Open
by clicking on the header. Now If there's no header, I'd like the Detail
fragment to always be open. This would be easy if there was a property like HeaderTitle.IsEmpty
.
<MyComp Open="false">
<HeaderTitle>
@if (!String.IsNullOrEmpty(hdr)) {
...
<div class="flex-grow"> @hdr </div>
}
</HeaderTitle>
<Detail>
...
</Detail>
</MyComp>
Edit
For further discussion I added a feature request here.
Old question, but as it is unanswered and getting upvotes....
A RenderFragment is a code method, not a container, so it does not have an Empty
state.
It can be null - which is equivalent to empty in the sense that it will produce no rendered output.
In the context of this question, you can effectively treat null
as Empty
- and simply have a method in your code
bool HeaderTitleIsEmpty => HeaderTitle is null;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With