How to configure the auto hide property for .NET MAUI BadgeView?
This article explains how to configure the AutoHide property for .NET MAUI BadgeView. The AutoHide property determines whether the badge should be automatically hidden when its value is zero or empty. By default, this property is set to false.
XAML
<VerticalStackLayout VerticalOptions="Center">
<badgeView:SfBadgeView x:Name="badgeView"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="120" HeightRequest="60" >
<badgeView:SfBadgeView.BadgeSettings>
<badgeView:BadgeSettings AutoHide="True"/>
</badgeView:SfBadgeView.BadgeSettings>
<badgeView:SfBadgeView.Content>
<Button Text="Click me"
BackgroundColor="HotPink"
WidthRequest="100"
HeightRequest="40"
Clicked="OnButtonClicked"
VerticalOptions="Center"
HorizontalOptions="Center" />
</badgeView:SfBadgeView.Content>
</badgeView:SfBadgeView>
</VerticalStackLayout>
Code Behind
int count = 0;
private void OnButtonClicked(object sender, EventArgs e)
{
count++;
if (count <= 3)
badgeView.BadgeText = $"{count}";
else
{
count = 0;
badgeView.BadgeText = $"{count}";
}
}
Output
AutoHide as True:
AutoHide as False:
Download the complete sample from GitHub
Conclusion
I hope you enjoyed learning how to configure the auto hide property for the .NET MAUI BadgeView.
You can refer to our .NET MAUI Badge View’s feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Badge View documentation to understand how to present and manipulate data.
For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our .NET MAUI Badge View and other .NET MAUI components.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!