We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Badge conditional visibility

How do I make the visibility of the badge itself conditional?  When I bind to the IsVisible property on the badgeview, the whole badge content becomes hidden.  I just want to hide the badge itself, such as for a selected item in a list.

3 Replies

RS Ramya Soundar Rajan Syncfusion Team January 23, 2020 09:02 AM UTC

Hi David, 
Thanks for contacting Syncfusion support. 
You can achieve this requirement in two ways. 
To hide the Badge, you can set empty string to BadgeText property as shown in the below code.  
        <badge:SfBadgeView BadgeText="" HorizontalOptions="Center" VerticalOptions="Center" Grid.Column="0"> 
                <Button Text="Primary" WidthRequest="120" HeightRequest="60"/> 
Another way to hide the Badge, by setting the BadgeIcon property as None without specifying the BadgeText as shown in the below code.  
Note: By default, BadgeIcon value is None.  
                <badge:BadgeSetting BadgeIcon="None"  BadgePosition="TopRight"/> 
We have created a simple sample to change the visibility of Badge. Please find the sample from below location. 
Output Screenshot: 

PP Paul Parkins March 24, 2021 11:08 AM UTC

Demo doesn't appear to work correctly on Android Emulator with SfBadgeView v17.4.0.44 as supplied in project, with the Android app re-targeted for Android 10. I find that the badge never shows, even when selection is "Visible".

Upgrading SfBadgeView to latest and Xamarin.Forms to v4.8 had no effect, still doesn't show the badge.

SS Sridevi Sivakumar Syncfusion Team March 25, 2021 10:15 AM UTC

Hi David Brenchley,

We have checked the reported query with the previously shared sample. In that sample, SfBadgeView BadgeText property not set properly, so that text is not displayed.

Now we have set the BadgeText based on index as per the below code snippet.

            private void Picker_SelectedIndexChanged(object sender, EventArgs e) 
            var picker = (Picker)sender; 
            int selectedIndex = picker.SelectedIndex; 
            if (selectedIndex == 0) 
                badgeView.BadgeText = "new"; 
                badgeView.BadgeText = ""; 

Please have a sample from below link

Let us know if you need any further assistance.

Sridevi S.

Live Chat Icon For mobile
Up arrow icon