Using MarkupString as value in Text in TabItem

I'm trying to set some HTML content in the Text of a Tab Item (to use Bootstrap badge styles). When I use MarkupString it is just still rendering as escaped HTML in the control (same function renders correctly outside of Radzen control). Is there additional escaping happening?

Example would be:
RadzenTabsItem Text="@RenderBadgeCount(15)"
where RenderBadgeCount is:
public MarkupString RenderBadgeCount(int count)
{
var badge = String.Format($"{count.ToString()}");
return new MarkupString(badge);
}

Yes, all Radzen components use string properties for rendering. Your example however doesn't use any markup - what are you trying to achieve?

We decided to implement a Template property which will allow to use MarkupString:

<RadzenTabsItem>
    <Template Context="tab">
         @RenderBadgeCount(15)
    </Template>
    <ChildContent>
        Tab content
    </ChildContent>
</RadzenTabsItem>

It is available in Radzen.Blazor 2.17.4

Awesome! I had not yet been on that version!

What I'm trying to do now I'm curious what the Radzen pattern might be. When the tab is selected I want the RenderBadgeCount function to return a different styled HTML depending on if the tab is selected or not. Change/SelectedIndexChanged only are giving me an int and not any object within that I can re-render. I may be thinking about this totally wrong from my WebForms days :slight_smile: -- any thoughts appreciated.

Basically when RenderBadgeCount is called I need to know if the tab is selected or not to render a diff style attribute.

Indeed that would be hard to do if you don't know that tab's index. At the moment all helpful methods and properties are internal. We will expose some of them e.g. the Index property of the item.

I just started a separate topic on this too. Selected is exposed but doesn’t seem to be updating with internal _IsSelected. Having that corrected as well as exposing Index would be good.

We will not correct that as it is by design (mentioned in your other thread's response).

We released Radzen.Blazor 2.17.7 where the IsSelected and Index property of the RadzenTabsItem are public. You can use IsSelected to determine if the item is selected in the template:

<Template Context="tab">
@if (tab.IsSelected)
{
    <strong>@tab.Text</strong>
}
else
{
    @tab.Text
}
</Template>