Skip to content

[iOS][Windows] Fix Label background not clipped when Clip property is set#34276

Draft
Shalini-Ashokan wants to merge 6 commits intodotnet:mainfrom
Shalini-Ashokan:fix-34114
Draft

[iOS][Windows] Fix Label background not clipped when Clip property is set#34276
Shalini-Ashokan wants to merge 6 commits intodotnet:mainfrom
Shalini-Ashokan:fix-34114

Conversation

@Shalini-Ashokan
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details

Label.Clip did not clip the background on iOS and Windows when Background was also set. The background rendered outside the clipping geometry.

Root Cause

When a Label has a non-null Background, LabelHandler.NeedsContainer returns true, wrapping the label in a WrapperView.

iOS: MapBackground called handler.ToPlatform(), which returns the WrapperView when a container is present. The background was applied to the wrapper, but WrapperView.SetClip() only masks sublayers named MauiBackgroundLayer — solid colors set via BackgroundColor are not sublayers, so they were never masked.

Windows: MapClip clipped only the child TextBlock's composition visual. The WrapperView's own Panel.Background visual was not subject to the child's clip.

Description of Change

iOS: Changed MapBackground to use handler.PlatformView?.UpdateBackground(label) (routes to MauiLabel) instead of handler.ToPlatform() (routes to WrapperView). The WrapperView clip then correctly clips the label and its background together.

Windows: Added a MapClip override for LabelHandler that also applies a CompositionGeometricClip to the WrapperView's own element visual via a new ClipSelf property, ensuring the wrapper background is clipped in sync with the child.

Validated the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #34114

Output ScreenShot

Before After
34114-Before.mov
34114-After.mov

@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34276

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34276"

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Feb 27, 2026
@dotnet-policy-service
Copy link
Contributor

Hey there @@Shalini-Ashokan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS, Mac, Windows] Label Clip Property Not Working Properly

1 participant