Is it possible to create a Badge without content

2 Answers 51 Views
BadgeView
Mark
Top achievements
Rank 3
Iron
Iron
Iron
Mark asked on 04 Aug 2023, 01:42 PM

I am looking to have aBadge which is basically a styled label sitting on its own.

I have tried adding a Badge View without content which wont work


<telerik:RadBadgeView BadgeText="Archived" BadgeHorizontalAlignment="Start" BackgroundColor="#ffc107" BadgeTextColor="Black">
                           <telerik:RadBadgeView.Content>
                                
                            </telerik:RadBadgeView.Content> 
                        </telerik:RadBadgeView>

Is there something I can do to just use the Badge as its own control?

2 Answers, 1 is accepted

Sort by
0
Accepted
Didi
Telerik team
answered on 04 Aug 2023, 02:12 PM

Hello Mark,

BadgeView is the control in which you can add content and position the badge based on this content. If you do not want to use BadgeView content and only badge (the indicator), then you can check the Badge control: https://docs.telerik.com/devtools/maui/controls/badgeview/badge-overview 

Regards,
Didi
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Mark
Top achievements
Rank 3
Iron
Iron
Iron
commented on 04 Aug 2023, 02:53 PM

Aha, thats what I need...

I did look for that control in the list of controls on the website, but was not there... only see BadgeView... will take a look...

Thanks
Mark
Top achievements
Rank 3
Iron
Iron
Iron
commented on 04 Aug 2023, 03:09 PM

 

This works as expected, just didn't know it was there.

Didi
Telerik team
commented on 04 Aug 2023, 03:47 PM

Hi Mark,

The Badge is described inside the BadgeView documentation as part of the control. We suggest using the BadgeView, but for your case if the Badge is enough, then you can use it.

0
Mark
Top achievements
Rank 3
Iron
Iron
Iron
answered on 04 Aug 2023, 01:49 PM
ok, I have done this to get something working:


<telerik:RadBadgeView BadgeText="Archived" BadgeHorizontalAlignment="Start" BadgeBackgroundColor="#ffc107" BadgeTextColor="Black" HorizontalOptions="Start" HeightRequest="25">
                           <telerik:RadBadgeView.Content>
                                <telerik:RadBorder WidthRequest="0" HeightRequest="20" BorderThickness="0" BorderColor="Transparent"></telerik:RadBorder>
                            </telerik:RadBadgeView.Content> 
                        </telerik:RadBadgeView>

Note: needed to put:

HeightRequest="20"

to give the badge space to render.

This works but seems a bit hacky and an overkill, any ideas on a more elegant solution
Tags
BadgeView
Asked by
Mark
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Didi
Telerik team
Mark
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or