Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue30404.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Microsoft.Maui.Controls.Shapes;
namespace Maui.Controls.Sample.Issues;

[Issue(IssueTracker.Github, 30404, "[Windows] ContentView clip is not updated when wrapping inside the Border", PlatformAffected.UWP)]
public class Issue30404 : ContentPage
{
public Issue30404()
{
var border = new Border
{
HeightRequest = 200,
BackgroundColor = Colors.Green,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};

var customView = new Issue30404CustomContentView
{
HeightRequest = 100,
WidthRequest = 100,
};

border.Content = customView;
Content = border;
}
}

public class Issue30404CustomContentView : ContentView
{
public Issue30404CustomContentView()
{
BackgroundColor = Colors.Red;
Content = new Label
{
Text = "Clipped Content",
TextColor = Colors.Blue,
AutomationId = "BorderContentLabel",
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};

SizeChanged += OnSizeChanged;
}

private void OnSizeChanged(object sender, EventArgs e)
{
if (Width > 0 && Height > 0)
{
Clip = new RoundRectangleGeometry(25, new Rect(0, 0, Width, Height));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#if TEST_FAILS_ON_IOS && TEST_FAILS_ON_CATALYST // Content of the border disappears when apply clip to it see https://github.com/dotnet/maui/issues/14164
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.TestCases.Tests.Issues;

public class Issue30404 : _IssuesUITest
{
public Issue30404(TestDevice device) : base(device) { }

public override string Issue => "[Windows] ContentView clip is not updated when wrapping inside the Border";

[Test]
[Category(UITestCategories.Border)]
public void ClipShouldApplyProperlyToTheContentOfBorder()
{
App.WaitForElement("BorderContentLabel");
VerifyScreenshot();
}
}
#endif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/Core/src/Platform/Windows/ContentPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ void UpdateClip(IShape? borderShape, double width, double height)
}

var visual = ElementCompositionPreview.GetElementVisual(Content);

// Prevent clip collision: When ContentView is inside Border, let WrapperView handle
// clipping to avoid Border overwriting ContentView's clip geometry during SizeChanged.
if (visual.Clip != null && Content.Parent is WrapperView)
{
return;
}
var compositor = visual.Compositor;

PathF? clipPath;
Expand Down
Loading