feat: add property Size.

This commit is contained in:
Zhang Dian
2024-06-07 18:09:36 +08:00
parent 8c53aea890
commit 9a79d7213c
6 changed files with 46 additions and 7 deletions

View File

@@ -38,6 +38,9 @@ public class Rating : TemplatedControl
public static readonly StyledProperty<double> DefaultValueProperty =
AvaloniaProperty.Register<Rating, double>(nameof(DefaultValue));
public static readonly StyledProperty<double> SizeProperty =
AvaloniaProperty.Register<RatingCharacter, double>(nameof(Size));
public static readonly StyledProperty<IDataTemplate?> ItemTemplateProperty =
AvaloniaProperty.Register<Rating, IDataTemplate?>(nameof(ItemTemplate));
@@ -83,6 +86,12 @@ public class Rating : TemplatedControl
set => SetValue(DefaultValueProperty, value);
}
public double Size
{
get => GetValue(SizeProperty);
set => SetValue(SizeProperty, value);
}
public IDataTemplate? ItemTemplate
{
get => GetValue(ItemTemplateProperty);
@@ -137,7 +146,8 @@ public class Rating : TemplatedControl
Items.Add(new RatingCharacter
{
Character = Character,
AllowHalf = AllowHalf
AllowHalf = AllowHalf,
Size = Size,
});
}
}
@@ -174,7 +184,8 @@ public class Rating : TemplatedControl
Items.Add(new RatingCharacter
{
Character = Character,
AllowHalf = AllowHalf
AllowHalf = AllowHalf,
Size = Size,
}
);
}