diff --git a/src/Ursa/Controls/Badge/Badge.cs b/src/Ursa/Controls/Badge/Badge.cs
index 5a583ee..51bf964 100644
--- a/src/Ursa/Controls/Badge/Badge.cs
+++ b/src/Ursa/Controls/Badge/Badge.cs
@@ -8,6 +8,9 @@ using Ursa.Common;
namespace Ursa.Controls;
+///
+/// Represents a Badge control that can display a notification indicator or count on top of other content.
+///
[TemplatePart(PART_BadgeContainer, typeof(Control))]
public class Badge : HeaderedContentControl
{
@@ -15,18 +18,33 @@ public class Badge : HeaderedContentControl
public const string PART_BadgeContainer = "PART_BadgeContainer";
public const string PART_HeaderPresenter = "PART_HeaderPresenter";
+ ///
+ /// Defines the theme applied to the badge.
+ ///
public static readonly StyledProperty BadgeThemeProperty =
AvaloniaProperty.Register(nameof(BadgeTheme));
+ ///
+ /// Defines whether the badge should be displayed as a dot.
+ ///
public static readonly StyledProperty DotProperty =
AvaloniaProperty.Register(nameof(Dot));
+ ///
+ /// Defines the corner position where the badge should be displayed.
+ ///
public static readonly StyledProperty CornerPositionProperty =
AvaloniaProperty.Register(nameof(CornerPosition));
+ ///
+ /// Defines the maximum count to display before showing overflow indicator.
+ ///
public static readonly StyledProperty OverflowCountProperty =
AvaloniaProperty.Register(nameof(OverflowCount));
+ ///
+ /// Defines the font size of the badge text.
+ ///
public static readonly StyledProperty BadgeFontSizeProperty =
AvaloniaProperty.Register(nameof(BadgeFontSize));
@@ -38,36 +56,52 @@ public class Badge : HeaderedContentControl
DotProperty.Changed.AddClassHandler((badge, _) => badge.UpdateBadgePosition());
}
+ ///
+ /// Gets or sets the theme applied to the badge.
+ ///
public ControlTheme BadgeTheme
{
get => GetValue(BadgeThemeProperty);
set => SetValue(BadgeThemeProperty, value);
}
+ ///
+ /// Gets or sets a value indicating whether the badge should be displayed as a dot.
+ ///
public bool Dot
{
get => GetValue(DotProperty);
set => SetValue(DotProperty, value);
}
+ ///
+ /// Gets or sets the corner position where the badge should be displayed.
+ ///
public CornerPosition CornerPosition
{
get => GetValue(CornerPositionProperty);
set => SetValue(CornerPositionProperty, value);
}
+ ///
+ /// Gets or sets the maximum count to display before showing overflow indicator.
+ ///
public int OverflowCount
{
get => GetValue(OverflowCountProperty);
set => SetValue(OverflowCountProperty, value);
}
+ ///
+ /// Gets or sets the font size of the badge text.
+ ///
public double BadgeFontSize
{
get => GetValue(BadgeFontSizeProperty);
set => SetValue(BadgeFontSizeProperty, value);
}
+ ///
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
_badgeContainer?.RemoveHandler(SizeChangedEvent, OnBadgeSizeChanged);
@@ -76,11 +110,17 @@ public class Badge : HeaderedContentControl
_badgeContainer?.AddHandler(SizeChangedEvent, OnBadgeSizeChanged);
}
+ ///
+ /// Handles the size changed event of the badge container and updates its position.
+ ///
private void OnBadgeSizeChanged(object? sender, SizeChangedEventArgs e)
{
UpdateBadgePosition();
}
+ ///
+ /// Updates the badge position based on the current corner position and size.
+ ///
private void UpdateBadgePosition()
{
var vertical = CornerPosition is CornerPosition.BottomLeft or CornerPosition.BottomRight ? 1 : -1;