Hi,
I am looking for a way to add a badge to a DxMenuItem.
I have seen the DxButton example. Tried to apply it on DxMenuItem:
Code<DxMenuItem Text="@Loc["Notifications"]"
IconCssClass="menuicon fa-solid fa-bell"
Visible="@isAuthenticated"
Context="notificationContext"
>
@notificationContext
<span class="badge">99</span>
</DxMenuItem>
But it results in an error: @notificationContext is not in current context.
So I tried with Template:
Code<DxMenuItem Text="@Loc["Notifications"]"
IconCssClass="menuicon fa-solid fa-bell"
Visible="@isAuthenticated"
Context="notificationContext"
>
<Template>
@notificationContext
<span class="badge">99</span>
</Template>
</DxMenuItem>
But this results in:
Next step: use Dxbutton with Template:
Code<DxMenuItem Text="@Loc["Notifications"]"
IconCssClass="menuicon fa-solid fa-bell"
Visible="@isAuthenticated"
Context="notificationContext"
>
<Template>
<DxButton Text = "@notificationContext.Text"
RenderStyle="ButtonRenderStyle.Link"
RenderStyleMode="ButtonRenderStyleMode.Text"
IconCssClass="@notificationContext.IconCssClass"
Context="buttonContext"
>
@buttonContext
<span class="badge">99</span>
</DxButton>
</Template>
</DxMenuItem>
Problems
- DxButton has another 'primary' color (hover) than the rest of the DxMenuItems.
- I am using a DxFormLayout to apply a selected SizeMode to all components. But is does not match:
Is there any easier way to implement badges?
Many thanks,
Lou Driehuis