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
close icon

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"> 
            <badge:SfBadgeView.Content> 
                <Button Text="Primary" WidthRequest="120" HeightRequest="60"/> 
            </badge:SfBadgeView.Content> 
        </badge:SfBadgeView> 
 
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:SfBadgeView.BadgeSettings> 
                <badge:BadgeSetting BadgeIcon="None"  BadgePosition="TopRight"/> 
            </badge:SfBadgeView.BadgeSettings> 
 
We have created a simple sample to change the visibility of Badge. Please find the sample from below location. 
 
 
Output Screenshot: 
 
 
 
Regards, 
Ramya. 



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 18.4.0.49 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.

[C#]:
 
            private void Picker_SelectedIndexChanged(object sender, EventArgs e) 
        { 
            var picker = (Picker)sender; 
            int selectedIndex = picker.SelectedIndex; 
            if (selectedIndex == 0) 
            { 
                badgeView.BadgeText = "new"; 
            } 
            else 
            { 
                badgeView.BadgeText = ""; 
            } 
        } 

Please have a sample from below link
https://www.syncfusion.com/downloads/support/directtrac/general/ze/BadgeViewDemo1950110264

Let us know if you need any further assistance.

Regards,
Sridevi S.
 


Loader.
Live Chat Icon For mobile
Up arrow icon