Skip to content

[Windows] Keep the shadow host out of XAML bounds so Border captures stay clipped - #40353

Merged
kubaflo merged 1 commit into
candidate/11.0.1xx-sr2from
fix-windows-border-shadow-capture
Nov 18, 2026
Merged

kubaflo merged 1 commit into
candidate/11.0.1xx-sr2from
fix-windows-border-shadow-capture

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
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!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it targets candidate/11.0.1xx-sr2 like the other candidate fixes (#40346, #40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

Failure: on the candidate, the Windows device test BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation: 0, translationX: 0, translationY: 0, hasShadow: true) fails in both packaged and unpackaged runs with (50,50) was (0,0,0,0) (expected red). The rows without a shadow pass. #40349 did not change this result.

Cause:

  • WrapperView hosts a view's DropShadow in a Rectangle (_shadowHost) whose only job is to carry the composition SpriteVisual. That Rectangle had Fill = Transparent.
  • A filled shape (even a transparent one) has XAML content bounds. RenderTargetBitmap sizes its capture from the element's inner bounds (its own content bounds plus the transformed bounds of its children) and ignores composition clips.
  • In this test the shadowed BoxView has Scale = 3 inside a 100×100 ellipse-clipped Border. The 84×84 shadow host under the same transform contributes 252×252 bounds at offset (76,76). The capture becomes 252×252 instead of 100×100, so pixel (50,50) falls in the transparent area outside the Border. The same view without a shadow contributes no extra bounds and captures at 100×100.
  • Why it surfaced now: UpdateShadowAsync awaits the alpha mask before UpdateShadowSize. Before [Windows] Fix Boxview shadow is not aligned with box view shape #40175 the mask came from an async RenderTargetBitmap, so the host was still 0×0 when the test captured. Since [Windows] Fix Boxview shadow is not aligned with box view shape #40175 (and [Windows] Render shape shadow masks offscreen so captures keep shadowed shapes #40349) the shape mask is produced synchronously, so the host is already sized when the capture runs.
  • The Transparent fill dates back to Shadow Support #570 and has no stated purpose.

Fix: create the shadow host without a Fill.

  • A WinUI shape with no Fill and no Stroke has empty content bounds (CShape::GenerateContentBounds), so it no longer enlarges captures.
  • Its hand-in composition visual (the shadow) still renders, because WinUI does not cull elements by XAML bounds.
  • The host also stops being hit-testable. Hit testing now matches the same view without a shadow. Previously, the transparent host could take input for an InputTransparent layout with a shadow, because Windows doesn't apply InputTransparent to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

Validation:

  • Compile check (macOS, Windows TFM): src/Core/src/Core.csproj with -p:TargetFrameworks=net11.0-windows10.0.19041.0 produces exactly the same errors as the unchanged base: 40, all in XAML code-behind files, because XAML compilation is disabled on macOS. None are in WrapperView.cs.
  • Windows runtime validation runs on this PR's device-test (maui-pr-devicetests) and UI-test (maui-pr-uitests) CI. The PR stays a draft until:
    • the Border shadow row passes;
    • the other Border rows stay green;
    • the Windows shadow and BoxView UI tests (for example ShadowFeatureTests and BoxViewFeatureTests) stay green.

Issues Fixed

Fixes the Windows BorderClipsTransformedContentToItsShape shadow-row failure on the SR2 candidate (#40116).

…stay clipped

WrapperView hosts a view's DropShadow in a Rectangle whose only job is to
carry the composition SpriteVisual. The Rectangle had a Transparent Fill,
which gives it XAML content bounds. RenderTargetBitmap sizes captures from
GetInnerBounds (content bounds plus transformed child bounds) and ignores
composition clips, so a shadowed, scaled view inside a clipped Border made
the capture larger than the Border and shifted its content.

Since #40175 the shape mask is produced synchronously, so the host is sized
before the capture and BorderTests.BorderClipsScaledContentWithShadow-style
rows fail with transparent pixels at the Border centre.

Leave the host without a Fill. A shape with no Fill/Stroke contributes no
content bounds and is not hit-testable, while its hand-in visual (the shadow)
still renders. This matches the same view without a shadow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 01:14 — with GitHub Actions Inactive
@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026
@MauiBot

MauiBot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Windows


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 0 findings

Reviewed commit b68eda2.

@kubaflo
kubaflo marked this pull request as ready for review November 18, 2026 03:56
@kubaflo

kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

The validation conditions in the description are met on this PR's CI for head b68eda2393 (merge 9b8b42f4e3):

  • Device tests, maui-pr-devicetests 1686843: completed succeeded. Windows Controls run 47076584: 2213 passed, 0 failed, including the Border BorderClipsTransformedContentToItsShape shadow row and the other Border rows.
  • UI tests, maui-pr-uitests 1686842: all Windows runs are complete.
    • Border,BoxView,Brush,Button (47078008): 225 passed, 0 failed.
    • Shadow (47076716): 16 passed, 0 failed.
    • SearchBar,Shape,Slider (47077670): 175 passed, 0 failed.
    • Layout (47077726): 186 passed, 0 failed.
  • The only Windows UI failure is Shell1 (47078280) ShellPages_FlowDirectionRTL, a visual check. This variable outcome was also seen in candidate build 1682289 and PR build 1683703, before this change. It does not involve shadows or Border.

Marking ready for review.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026
@MauiBot

MauiBot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Windows


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 0 findings

Reviewed commit b68eda2.

@kubaflo kubaflo mentioned this pull request Nov 18, 2026
1 task
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo merged commit 01cf41a into candidate/11.0.1xx-sr2 Nov 18, 2026
179 of 191 checks passed
@kubaflo
kubaflo deleted the fix-windows-border-shadow-capture branch November 18, 2026 10:48
kubaflo added a commit that referenced this pull request Nov 18, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…stay clipped (#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR #40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (#40346,
#40348, #40349, #40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. #40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before #40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since #40175 (and #40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to #570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…stay clipped (dotnet#40353)

<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

This is a candidate-acceptance fix for SR2 candidate PR dotnet#40116, so it
targets `candidate/11.0.1xx-sr2` like the other candidate fixes (dotnet#40346,
dotnet#40348, dotnet#40349, dotnet#40350).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

**Failure:** on the candidate, the Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(scale: 3, rotation:
0, translationX: 0, translationY: 0, hasShadow: true)` fails in both
packaged and unpackaged runs with `(50,50) was (0,0,0,0)` (expected
red). The rows without a shadow pass. dotnet#40349 did not change this result.

**Cause:**
- `WrapperView` hosts a view's `DropShadow` in a `Rectangle`
(`_shadowHost`) whose only job is to carry the composition
`SpriteVisual`. That Rectangle had `Fill = Transparent`.
- A filled shape (even a transparent one) has XAML content bounds.
`RenderTargetBitmap` sizes its capture from the element's inner bounds
(its own content bounds plus the transformed bounds of its children) and
ignores composition clips.
- In this test the shadowed BoxView has `Scale = 3` inside a 100×100
ellipse-clipped Border. The 84×84 shadow host under the same transform
contributes 252×252 bounds at offset (76,76). The capture becomes
252×252 instead of 100×100, so pixel (50,50) falls in the transparent
area outside the Border. The same view without a shadow contributes no
extra bounds and captures at 100×100.
- **Why it surfaced now:** `UpdateShadowAsync` awaits the alpha mask
before `UpdateShadowSize`. Before dotnet#40175 the mask came from an async
`RenderTargetBitmap`, so the host was still 0×0 when the test captured.
Since dotnet#40175 (and dotnet#40349) the shape mask is produced synchronously, so
the host is already sized when the capture runs.
- The Transparent fill dates back to dotnet#570 and has no stated purpose.

**Fix:** create the shadow host without a `Fill`.
- A WinUI shape with no Fill and no Stroke has empty content bounds
(`CShape::GenerateContentBounds`), so it no longer enlarges captures.
- Its hand-in composition visual (the shadow) still renders, because
WinUI does not cull elements by XAML bounds.
- The host also stops being hit-testable. Hit testing now matches the
same view without a shadow. Previously, the transparent host could take
input for an `InputTransparent` layout with a shadow, because Windows
doesn't apply `InputTransparent` to the wrapper for layouts.

No tests, baselines, tolerances or waits are changed.

**Validation:**
- Compile check (macOS, Windows TFM): `src/Core/src/Core.csproj` with
`-p:TargetFrameworks=net11.0-windows10.0.19041.0` produces exactly the
same errors as the unchanged base: 40, all in XAML code-behind files,
because XAML compilation is disabled on macOS. None are in
`WrapperView.cs`.
- Windows runtime validation runs on this PR's device-test
(`maui-pr-devicetests`) and UI-test (`maui-pr-uitests`) CI. The PR stays
a draft until:
  - the Border shadow row passes;
  - the other Border rows stay green;
- the Windows shadow and BoxView UI tests (for example
`ShadowFeatureTests` and `BoxViewFeatureTests`) stay green.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape` shadow-row
failure on the SR2 candidate (dotnet#40116).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — b68eda23 Deployed Nov 18, 2026 by kubaflo via conclusion #3057
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants