Skip to content

Commit

Permalink
Set default to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo committed Nov 2, 2024
1 parent 9a4e636 commit 0dd9c15
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Controls/src/Core/BorderElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static class BorderElement
propertyChanged: OnBorderColorPropertyChanged);

/// <summary>Bindable property for <see cref="IBorderElement.BorderWidth"/>.</summary>
public static readonly BindableProperty BorderWidthProperty = BindableProperty.Create(nameof(IBorderElement.BorderWidth), typeof(double), typeof(IBorderElement), -1d);
public static readonly BindableProperty BorderWidthProperty = BindableProperty.Create(nameof(IBorderElement.BorderWidth), typeof(double), typeof(IBorderElement), 0d);

/// <summary>Bindable property for <see cref="IBorderElement.CornerRadius"/>.</summary>
public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(nameof(IBorderElement.CornerRadius), typeof(int), typeof(IBorderElement), defaultValue: DefaultCornerRadius);
Expand Down
17 changes: 1 addition & 16 deletions src/Controls/src/Core/RadioButton/RadioButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,7 @@ static View BuildDefaultTemplate()

border.SetBinding(Border.StrokeProperty, static (RadioButton rb) => rb.BorderColor, source: RelativeBindingSource.TemplatedParent);
border.SetBinding(Border.StrokeShapeProperty, static (RadioButton rb) => rb.CornerRadius, source: RelativeBindingSource.TemplatedParent, converter: new CornerRadiusToShape());

// NonNegativeValueConverter ensures that StrokeThickness remains non-negative as the default value of -1 triggers a CGContextSetLineWidth error on iOS.
border.SetBinding(Border.StrokeThicknessProperty, static (RadioButton rb) => rb.BorderWidth, source: RelativeBindingSource.TemplatedParent, converter: new NonNegativeValueConverter());
border.SetBinding(Border.StrokeThicknessProperty, static (RadioButton rb) => rb.BorderWidth, source: RelativeBindingSource.TemplatedParent);

var grid = new Grid
{
Expand Down Expand Up @@ -696,18 +694,5 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
throw new NotImplementedException();
}
}

class NonNegativeValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return Math.Max(0, (double)value);
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
}

0 comments on commit 0dd9c15

Please sign in to comment.