From 5fc2c33fed08d7a5f0f3bb576fea7d654c1d7157 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:14:05 +0800 Subject: [PATCH] feat: simple avatar group. --- demo/Ursa.Demo/Pages/AvatarDemo.axaml | 9 +++++++++ src/Ursa.Themes.Semi/Controls/Avatar.axaml | 13 +++++++++---- src/Ursa/Controls/Avatar/AvatarGroup.cs | 15 +++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml index f8459f5..a561b3b 100644 --- a/demo/Ursa.Demo/Pages/AvatarDemo.axaml +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -64,5 +64,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml index 0714791..0f5676c 100644 --- a/src/Ursa.Themes.Semi/Controls/Avatar.axaml +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -21,9 +21,7 @@ RadiusX="{Binding #PART_Ellipse.Bounds.Width, Converter={StaticResource DivideByTwoConverter}}" RadiusY="{Binding #PART_Ellipse.Bounds.Height, Converter={StaticResource DivideByTwoConverter}}" /> - + @@ -131,5 +129,12 @@ - + + + + + + + + \ No newline at end of file diff --git a/src/Ursa/Controls/Avatar/AvatarGroup.cs b/src/Ursa/Controls/Avatar/AvatarGroup.cs index 60e86b7..300a3f6 100644 --- a/src/Ursa/Controls/Avatar/AvatarGroup.cs +++ b/src/Ursa/Controls/Avatar/AvatarGroup.cs @@ -1,5 +1,7 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Templates; +using Avalonia.Layout; namespace Ursa.Controls; @@ -7,11 +9,15 @@ public class AvatarGroup : ItemsControl { public const string PART_RenderMore = "PART_RenderMore"; + private static readonly FuncTemplate DefaultPanel = + new(() => new StackPanel { Orientation = Orientation.Horizontal }); + public static readonly StyledProperty MaxCountProperty = AvaloniaProperty.Register( nameof(MaxCount)); - public static readonly StyledProperty OverlapFromProperty = AvaloniaProperty.Register( - nameof(OverlapFrom)); + public static readonly StyledProperty OverlapFromProperty = + AvaloniaProperty.Register( + nameof(OverlapFrom)); public int MaxCount { @@ -24,6 +30,11 @@ public class AvatarGroup : ItemsControl get => GetValue(OverlapFromProperty); set => SetValue(OverlapFromProperty, value); } + + static AvatarGroup() + { + ItemsPanelProperty.OverrideDefaultValue(DefaultPanel); + } } public enum OverlapFromType