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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Badge conditional visibility

Thread ID:

Created:

Updated:

Platform:

Replies:

150875 Jan 22,2020 06:23 PM UTC Mar 25,2021 10:15 AM UTC Xamarin.Forms 3
loading
Tags: SfBadgeView
David Brenchley
Asked On January 22, 2020 06:23 PM UTC

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.

Ramya Soundar Rajan [Syncfusion]
Replied On 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. 


Paul Parkins
Replied On 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.


Sridevi Sivakumar [Syncfusion]
Replied On 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.
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon