diff --git a/src/Controls/src/Core/Shapes/Shape.cs b/src/Controls/src/Core/Shapes/Shape.cs index c295f9c765d0..92e6df2be1ac 100644 --- a/src/Controls/src/Core/Shapes/Shape.cs +++ b/src/Controls/src/Core/Shapes/Shape.cs @@ -376,7 +376,7 @@ protected override Size MeasureOverride(double widthConstraint, double heightCon var result = base.MeasureOverride(widthConstraint, heightConstraint); RectF pathBounds; - if (result.Width != 0 && result.Height != 0) + if (result.Width != 0 && result.Height != 0 && result.Width > Margin.HorizontalThickness && result.Height > Margin.VerticalThickness) { return result; } @@ -391,7 +391,7 @@ protected override Size MeasureOverride(double widthConstraint, double heightCon } else { - pathBounds = this.GetPath().GetBoundsByFlattening(1); + pathBounds = this.GetPath().GetBoundsByFlattening(1); } SizeF boundsByFlattening = pathBounds.Size; @@ -450,6 +450,12 @@ protected override Size MeasureOverride(double widthConstraint, double heightCon result.Height += StrokeThickness; result.Width += StrokeThickness; + if (this is Line or Path or Polyline) + { + result.Height += Margin.VerticalThickness; + result.Width += Margin.HorizontalThickness; + } + return result; } diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue13801VerifyPathMargin.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue13801VerifyPathMargin.png new file mode 100644 index 000000000000..b7dcd041561d Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/Issue13801VerifyPathMargin.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml new file mode 100644 index 000000000000..cf360a079935 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml @@ -0,0 +1,46 @@ + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml.cs new file mode 100644 index 000000000000..a068bca60d21 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue13801.xaml.cs @@ -0,0 +1,11 @@ +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 13801, "Path does not render if it has Margin", PlatformAffected.All)] + public partial class Issue13801 : ContentPage + { + public Issue13801() + { + InitializeComponent(); + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue13801VerifyPathMargin.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue13801VerifyPathMargin.png new file mode 100644 index 000000000000..8ef2e459fb01 Binary files /dev/null and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/Issue13801VerifyPathMargin.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue13801.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue13801.cs new file mode 100644 index 000000000000..27743209f63d --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue13801.cs @@ -0,0 +1,21 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue13801 : _IssuesUITest + { + public override string Issue => "Path does not render if it has Margin"; + + public Issue13801(TestDevice testDevice) : base(testDevice) { } + + [Test] + [Category(UITestCategories.Shape)] + public void Issue13801VerifyPathMargin() + { + App.WaitForElement("PathLabel"); + VerifyScreenshot(); + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue13801VerifyPathMargin.png b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue13801VerifyPathMargin.png new file mode 100644 index 000000000000..4970f7cc8d20 Binary files /dev/null and b/src/Controls/tests/TestCases.WinUI.Tests/snapshots/windows/Issue13801VerifyPathMargin.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue13801VerifyPathMargin.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue13801VerifyPathMargin.png new file mode 100644 index 000000000000..9791adbd1540 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/Issue13801VerifyPathMargin.png differ