Skip to content

Commit 4149f2e

Browse files
Use PropertyChanging for ShapeBorderThickness range validation
1 parent d9a5085 commit 4149f2e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/CommunityToolkit.Maui/Views/RatingView/RatingView.shared.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public event EventHandler<RatingChangedEventArgs> RatingChanged
6969
/// </summary>
7070
/// <remarks>A value of 0 indicates that no border will be rendered. Negative values are not supported and may
7171
/// result in undefined behavior.</remarks>
72-
[BindableProperty(DefaultValue = RatingViewDefaults.ShapeBorderThickness, PropertyChangedMethodName = nameof(OnShapeBorderThicknessChanged))]
72+
[BindableProperty(DefaultValue = RatingViewDefaults.ShapeBorderThickness, PropertyChangedMethodName = nameof(OnShapeBorderThicknessChanged), PropertyChangingMethodName = nameof(OnShapeBorderThicknessChanging))]
7373
public partial double ShapeBorderThickness { get; set; }
7474

7575
/// <summary>
@@ -360,13 +360,16 @@ static void OnShapeBorderColorChanged(BindableObject bindable, object oldValue,
360360
}
361361
}
362362

363-
static void OnShapeBorderThicknessChanged(BindableObject bindable, object oldValue, object newValue)
363+
static void OnShapeBorderThicknessChanging(BindableObject bindable, object oldValue, object newValue)
364364
{
365365
if ((double)newValue < 0)
366366
{
367367
throw new ArgumentOutOfRangeException(nameof(newValue), $"{nameof(ShapeBorderThickness)} must be greater than 0");
368368
}
369+
}
369370

371+
static void OnShapeBorderThicknessChanged(BindableObject bindable, object oldValue, object newValue)
372+
{
370373
var ratingView = (RatingView)bindable;
371374
for (var element = 0; element < ratingView.RatingLayout.Count; element++)
372375
{

0 commit comments

Comments
 (0)