fix: fix AllowHalf initialization.

This commit is contained in:
Zhang Dian
2024-06-06 17:23:29 +08:00
parent 8d1ff56e85
commit ee2e4c4395
2 changed files with 5 additions and 10 deletions

View File

@@ -179,16 +179,13 @@ public class Rating : TemplatedControl
Items.Add(new RatingCharacter());
}
foreach (var item in Items)
{
item.AllowHalf = AllowHalf;
}
SetCurrentValue(ValueProperty, DefaultValue);
}
protected override void OnLoaded(RoutedEventArgs e)
{
base.OnLoaded(e);
UpdateItemsByValue(Value);
AdjustWidth(Value);
}
public void Preview(RatingCharacter o)
{
var index = Items.IndexOf(o);

View File

@@ -17,9 +17,7 @@ public class RatingCharacter : TemplatedControl
private Control? _icon;
public static readonly StyledProperty<bool> AllowHalfProperty = AvaloniaProperty.Register<RatingCharacter, bool>(
nameof(AllowHalf));
public static readonly StyledProperty<bool> AllowHalfProperty = Rating.AllowHalfProperty.AddOwner<RatingCharacter>();
public bool AllowHalf
{