Skip to content

Commit

Permalink
[C] fix BP declaration for Border (#8047)
Browse files Browse the repository at this point in the history
- fixes #7744
  • Loading branch information
StephaneDelcroix authored and rmarinho committed Jun 23, 2022
1 parent 3113d68 commit f3371ba
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Controls/src/Core/Border.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@ public Thickness Padding
}

public static readonly BindableProperty StrokeShapeProperty =
BindableProperty.Create(nameof(StrokeShape), typeof(IShape), typeof(Layout), null);
BindableProperty.Create(nameof(StrokeShape), typeof(IShape), typeof(Border), null);

public static readonly BindableProperty StrokeProperty =
BindableProperty.Create(nameof(Stroke), typeof(Brush), typeof(Layout), null);
BindableProperty.Create(nameof(Stroke), typeof(Brush), typeof(Border), null);

public static readonly BindableProperty StrokeThicknessProperty =
BindableProperty.Create(nameof(StrokeThickness), typeof(double), typeof(Layout), 1.0, propertyChanged: StrokeThicknessChanged);
BindableProperty.Create(nameof(StrokeThickness), typeof(double), typeof(Border), 1.0, propertyChanged: StrokeThicknessChanged);

public static readonly BindableProperty StrokeDashArrayProperty =
BindableProperty.Create(nameof(StrokeDashArray), typeof(DoubleCollection), typeof(Layout), null,
BindableProperty.Create(nameof(StrokeDashArray), typeof(DoubleCollection), typeof(Border), null,
defaultValueCreator: bindable => new DoubleCollection());

public static readonly BindableProperty StrokeDashOffsetProperty =
BindableProperty.Create(nameof(StrokeDashOffset), typeof(double), typeof(Layout), 0.0);
BindableProperty.Create(nameof(StrokeDashOffset), typeof(double), typeof(Border), 0.0);

public static readonly BindableProperty StrokeLineCapProperty =
BindableProperty.Create(nameof(StrokeLineCap), typeof(PenLineCap), typeof(Layout), PenLineCap.Flat);
BindableProperty.Create(nameof(StrokeLineCap), typeof(PenLineCap), typeof(Border), PenLineCap.Flat);

public static readonly BindableProperty StrokeLineJoinProperty =
BindableProperty.Create(nameof(StrokeLineJoin), typeof(PenLineJoin), typeof(Layout), PenLineJoin.Miter);
BindableProperty.Create(nameof(StrokeLineJoin), typeof(PenLineJoin), typeof(Border), PenLineJoin.Miter);

public static readonly BindableProperty StrokeMiterLimitProperty =
BindableProperty.Create(nameof(StrokeMiterLimit), typeof(double), typeof(Layout), 10.0);
BindableProperty.Create(nameof(StrokeMiterLimit), typeof(double), typeof(Border), 10.0);

[System.ComponentModel.TypeConverter(typeof(StrokeShapeTypeConverter))]
public IShape? StrokeShape
Expand Down
17 changes: 17 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui7744.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests"
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui7744">

<StackLayout>
<Border x:Name="border0" StrokeShape="RoundRectangle 1,1,1,1"/>
<Border x:Name="border1">
<Border.Style>
<Style TargetType="Border">
<Setter Property="StrokeShape" Value="RoundRectangle 1,1,1,1"/>
</Style>
</Border.Style>
</Border>
</StackLayout>
</ContentPage>
32 changes: 32 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui7744.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Controls.Core.UnitTests;
using Microsoft.Maui.Controls.Shapes;
using Microsoft.Maui.Devices;
using NUnit.Framework;

namespace Microsoft.Maui.Controls.Xaml.UnitTests
{
public partial class Maui7744 : ContentPage
{
public Maui7744() => InitializeComponent();
public Maui7744(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}

[TestFixture]
class Test
{
[SetUp] public void Setup() => AppInfo.SetCurrent(new MockAppInfo());
[TearDown] public void TearDown() => AppInfo.SetCurrent(null);

[Test]
public void ConvertersAreExecutedWhileApplyingSetter([Values(false, true)] bool useCompiledXaml)
{
var page = new Maui7744(useCompiledXaml);
Assert.That(page.border0.StrokeShape, Is.TypeOf<RoundRectangle>());
Assert.That(page.border1.StrokeShape, Is.TypeOf<RoundRectangle>());
}
}
}
}

0 comments on commit f3371ba

Please sign in to comment.