[iOS][Windows] Fix Label background not clipped when Clip property is set#34276
Draft
Shalini-Ashokan wants to merge 6 commits intodotnet:mainfrom
Draft
[iOS][Windows] Fix Label background not clipped when Clip property is set#34276Shalini-Ashokan wants to merge 6 commits intodotnet:mainfrom
Shalini-Ashokan wants to merge 6 commits intodotnet:mainfrom
Conversation
This reverts commit 27faf8a.
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34276Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34276" |
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. |
This was referenced Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Backgroundwas 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
Issues Fixed
Fixes #34114
Output ScreenShot
34114-Before.mov
34114-After.mov