diff --git a/src/Ursa.Themes.Semi/Controls/DualBadge.axaml b/src/Ursa.Themes.Semi/Controls/DualBadge.axaml
index 80b36f0..a8b10ba 100644
--- a/src/Ursa.Themes.Semi/Controls/DualBadge.axaml
+++ b/src/Ursa.Themes.Semi/Controls/DualBadge.axaml
@@ -11,7 +11,7 @@
-
+
@@ -22,7 +22,7 @@
VerticalAlignment="{TemplateBinding VerticalAlignment}"
ClipToBounds="True"
CornerRadius="{TemplateBinding CornerRadius}">
-
+
@@ -43,7 +43,7 @@
Foreground="{TemplateBinding HeaderForeground}"
Padding="{TemplateBinding Padding}"
Content="{TemplateBinding Header}"
- ContentTemplate="{TemplateBinding HeaderTemplate}"/>
+ ContentTemplate="{TemplateBinding HeaderTemplate}" />
\ No newline at end of file
diff --git a/src/Ursa/Controls/DualBadge.cs b/src/Ursa/Controls/DualBadge.cs
index 9e445c6..de6df7c 100644
--- a/src/Ursa/Controls/DualBadge.cs
+++ b/src/Ursa/Controls/DualBadge.cs
@@ -4,6 +4,7 @@ using Avalonia.Controls.Metadata;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
+using Avalonia.Interactivity;
using Avalonia.Media;
namespace Ursa.Controls;
@@ -64,56 +65,33 @@ public class DualBadge : HeaderedContentControl
set => SetValue(HeaderBackgroundProperty, value);
}
- public static readonly StyledProperty IsIconEmptyProperty = AvaloniaProperty.Register(
- nameof(IsIconEmpty));
-
- public bool IsIconEmpty
- {
- get => GetValue(IsIconEmptyProperty);
- set => SetValue(IsIconEmptyProperty, value);
- }
-
- public static readonly StyledProperty IsHeaderEmptyProperty = AvaloniaProperty.Register(
- nameof(IsHeaderEmpty));
-
- public bool IsHeaderEmpty
- {
- get => GetValue(IsHeaderEmptyProperty);
- set => SetValue(IsHeaderEmptyProperty, value);
- }
-
- public static readonly StyledProperty IsContentEmptyProperty = AvaloniaProperty.Register(
- nameof(IsContentEmpty));
-
- public bool IsContentEmpty
- {
- get => GetValue(IsContentEmptyProperty);
- set => SetValue(IsContentEmptyProperty, value);
- }
-
-
static DualBadge()
{
- IsIconEmptyProperty.Changed.AddClassHandler((o, e) => o.OnIsIconEmptyChanged(e));
- IsHeaderEmptyProperty.Changed.AddClassHandler((o, e) => o.OnIsHeaderEmptyChanged(e));
- IsContentEmptyProperty.Changed.AddClassHandler((o, e) => o.OnIsContentEmptyChanged(e));
+ IconProperty.Changed.AddClassHandler((o, args) => o.OnIconChanged());
+ HeaderProperty.Changed.AddClassHandler((o, args) => o.OnHeaderChanged());
+ ContentProperty.Changed.AddClassHandler((o, args) => o.OnContentChanged());
}
- private void OnIsIconEmptyChanged(AvaloniaPropertyChangedEventArgs args)
+ protected override void OnLoaded(RoutedEventArgs e)
{
- bool newValue = args.GetNewValue();
- PseudoClasses.Set(PC_IconEmpty, newValue);
+ base.OnLoaded(e);
+ OnIconChanged();
+ OnHeaderChanged();
+ OnContentChanged();
}
- private void OnIsHeaderEmptyChanged(AvaloniaPropertyChangedEventArgs args)
+ private void OnIconChanged()
{
- bool newValue = args.GetNewValue();
- PseudoClasses.Set(PC_HeaderEmpty, newValue);
+ PseudoClasses.Set(PC_IconEmpty, Icon is null);
}
- private void OnIsContentEmptyChanged(AvaloniaPropertyChangedEventArgs args)
+ private void OnHeaderChanged()
{
- bool newValue = args.GetNewValue();
- PseudoClasses.Set(PC_ContentEmpty, newValue);
+ PseudoClasses.Set(PC_HeaderEmpty, Header is null);
+ }
+
+ private void OnContentChanged()
+ {
+ PseudoClasses.Set(PC_ContentEmpty, Content is null);
}
}
\ No newline at end of file