Skip to content

[Windows] Render shape shadow masks offscreen so captures keep shadowed shapes - #40349

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

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

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 17, 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 repair for the SR2 candidate (#40116), so it targets candidate/11.0.1xx-sr2 as assigned.

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

Regression. The Windows device test BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0, hasShadow: true) fails deterministically on net11 and on the candidate with pixel (50,50) expected red, was (0,0,0,0). It passes on main.

  • The onset is [Windows] Fix Boxview shadow is not aligned with box view shape #40175 (ea39223fd0 on net11, 219a32fbcc on the candidate). net11 device build 1680463 (b2d31412a9) passed, and the next build, 1680671 (ea39223fd0), failed.
  • [Windows] Fix Boxview shadow is not aligned with box view shape #40175's only product change is in ShadowExtensions.cs. For a W2DGraphicsView with a ShapeDrawable, it replaced the static mask with a live CompositionVisualSurface whose SourceVisual is the element's own visual.
  • With that surface attached, the shape's content is missing from RenderTargetBitmap captures. That covers the device test's RawBitmap capture and CaptureAsync on Windows. The hasShadow:false rows of the same theory still capture the Win2D content, so RenderTargetBitmap itself does capture Win2D content.

Fix (this keeps #40175's goal from #31821, a shadow that follows the shape):

  • ShadowExtensions.GetShapeAlphaMask draws the view's ShapeDrawable into an offscreen Win2D CanvasRenderTarget and uses the result as a static DropShadow mask, the same kind of mask other elements get. It mirrors W2DGraphicsView.OnDraw: it uses the rasterization-scale DPI, the logical-size scale correction and the RTL flip. It doesn't depend on whether the CanvasControl has drawn yet.
  • Because the mask is a snapshot, ShapesExtensions.UpdateShape and ShapesExtensions.InvalidateShape now call a new internal WrapperView.InvalidateShadow(). It refreshes the mask only when a shadow exists, so the shadow keeps following shape changes such as corner radius, aspect or flow direction made after the shadow is set. Size, shadow and clip changes already refreshed the mask through UpdateShadowAsync.

There are no public API changes, no test changes and no baseline or tolerance changes.

Validation

  • Baseline red: the row fails deterministically in net11 and candidate Windows device builds, starting exactly at [Windows] Fix Boxview shadow is not aligned with box view shape #40175, as described above.
  • Windows TFM compile on macOS: dotnet build src/Core/src/Core.csproj -p:TargetFrameworks=net11.0-windows10.0.19041.0 -p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true -p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false -p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false.
    • Passed for the changed files: they produced 0 errors. The build still fails with only the known errors from code that XAML codegen would generate (MauiToolbar.xaml.cs, RootNavigationView.cs, NavigationRootManager.cs), which macOS can't run.
    • Negative controls prove the changed files are compiled. Injecting int x = "x"; produced CS0029 in ShadowExtensions.cs, ShapesExtensions.cs and WrapperView.cs. The controls were then reverted.
  • dotnet format whitespace --folder --verify-no-changes --include <3 changed files>: passed.
  • Not run locally: I have no Windows host, so the Windows runtime legs (fix green, fix reverted red, restored green) couldn't be produced locally. This PR's CI has to show them: maui-pr-devicetests Windows Border (BorderClipsTransformedContentToItsShape) and maui-pr-uitests Windows BoxView/Shadow snapshots. Those snapshots include [Windows] Fix Boxview shadow is not aligned with box view shape #40175's BoxView_*AndShadow baselines, which have not been changed here.

Issues Fixed

Fixes the Windows BorderClipsTransformedContentToItsShape(hasShadow: true) regression found while validating #40116. It keeps the shape-following shadow fix for #31821.

…ed shapes

#40175 made BoxView/shape shadows use a live CompositionVisualSurface of the
element as the DropShadow mask. With that surface attached, the shape's own
content is missing from RenderTargetBitmap captures, so the Windows device test
BorderClipsTransformedContentToItsShape(hasShadow: true) reads a transparent
pixel where the red BoxView should be.

Render the ShapeDrawable into an offscreen Win2D CanvasRenderTarget instead,
mirroring W2DGraphicsView's draw (logical-size scale and RTL flip), and use it
as a static mask. Refresh the mask when the shape is replaced or invalidated so
the shadow keeps following shape changes, as #40175 intended.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 17, 2026 22:27 — 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 17, 2026
@kubaflo

kubaflo commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

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

Result INCONCLUSIVE Platform Android


🧪 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 17, 2026
@kubaflo
kubaflo merged commit d7ecc0a into candidate/11.0.1xx-sr2 Nov 17, 2026
30 of 69 checks passed
@kubaflo
kubaflo deleted the fix-windows-shape-shadow-capture branch November 17, 2026 23:53
@kubaflo kubaflo mentioned this pull request Nov 18, 2026
1 task
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
…ed shapes (#40349)

<!-- 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 repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

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

**Regression.** The Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0,
hasShadow: true)` fails deterministically on net11 and on the candidate
with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`.
- The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the
candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the
next build, 1680671 (`ea39223fd0`), failed.
- #40175's only product change is in `ShadowExtensions.cs`. For a
`W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask
with a live `CompositionVisualSurface` whose `SourceVisual` is the
element's own visual.
- With that surface attached, the shape's content is missing from
`RenderTargetBitmap` captures. That covers the device test's `RawBitmap`
capture and `CaptureAsync` on Windows. The hasShadow:false rows of the
same theory still capture the Win2D content, so `RenderTargetBitmap`
itself does capture Win2D content.

**Fix** (this keeps #40175's goal from #31821, a shadow that follows the
shape):
- `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable`
into an offscreen Win2D `CanvasRenderTarget` and uses the result as a
static `DropShadow` mask, the same kind of mask other elements get. It
mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI,
the logical-size scale correction and the RTL flip. It doesn't depend on
whether the `CanvasControl` has drawn yet.
- Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and
`ShapesExtensions.InvalidateShape` now call a new internal
`WrapperView.InvalidateShadow()`. It refreshes the mask only when a
shadow exists, so the shadow keeps following shape changes such as
corner radius, aspect or flow direction made after the shadow is set.
Size, shadow and clip changes already refreshed the mask through
`UpdateShadowAsync`.

There are no public API changes, no test changes and no baseline or
tolerance changes.

**Validation**
- Baseline red: the row fails deterministically in net11 and candidate
Windows device builds, starting exactly at #40175, as described above.
- Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj
-p:TargetFrameworks=net11.0-windows10.0.19041.0
-p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true
-p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false
-p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`.
- **Passed** for the changed files: they produced 0 errors. The build
still fails with only the known errors from code that XAML codegen would
generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`,
`NavigationRootManager.cs`), which macOS can't run.
- Negative controls prove the changed files are compiled. Injecting `int
x = "x";` produced CS0029 in `ShadowExtensions.cs`,
`ShapesExtensions.cs` and `WrapperView.cs`. The controls were then
reverted.
- `dotnet format whitespace --folder --verify-no-changes --include <3
changed files>`: **passed**.
- **Not run locally:** I have no Windows host, so the Windows runtime
legs (fix green, fix reverted red, restored green) couldn't be produced
locally. This PR's CI has to show them: `maui-pr-devicetests` Windows
Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests`
Windows BoxView/Shadow snapshots. Those snapshots include #40175's
`BoxView_*AndShadow` baselines, which have not been changed here.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow:
true)` regression found while validating #40116. It keeps the
shape-following shadow fix for #31821.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

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
…ed shapes (#40349)

<!-- 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 repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

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

**Regression.** The Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0,
hasShadow: true)` fails deterministically on net11 and on the candidate
with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`.
- The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the
candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the
next build, 1680671 (`ea39223fd0`), failed.
- #40175's only product change is in `ShadowExtensions.cs`. For a
`W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask
with a live `CompositionVisualSurface` whose `SourceVisual` is the
element's own visual.
- With that surface attached, the shape's content is missing from
`RenderTargetBitmap` captures. That covers the device test's `RawBitmap`
capture and `CaptureAsync` on Windows. The hasShadow:false rows of the
same theory still capture the Win2D content, so `RenderTargetBitmap`
itself does capture Win2D content.

**Fix** (this keeps #40175's goal from #31821, a shadow that follows the
shape):
- `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable`
into an offscreen Win2D `CanvasRenderTarget` and uses the result as a
static `DropShadow` mask, the same kind of mask other elements get. It
mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI,
the logical-size scale correction and the RTL flip. It doesn't depend on
whether the `CanvasControl` has drawn yet.
- Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and
`ShapesExtensions.InvalidateShape` now call a new internal
`WrapperView.InvalidateShadow()`. It refreshes the mask only when a
shadow exists, so the shadow keeps following shape changes such as
corner radius, aspect or flow direction made after the shadow is set.
Size, shadow and clip changes already refreshed the mask through
`UpdateShadowAsync`.

There are no public API changes, no test changes and no baseline or
tolerance changes.

**Validation**
- Baseline red: the row fails deterministically in net11 and candidate
Windows device builds, starting exactly at #40175, as described above.
- Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj
-p:TargetFrameworks=net11.0-windows10.0.19041.0
-p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true
-p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false
-p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`.
- **Passed** for the changed files: they produced 0 errors. The build
still fails with only the known errors from code that XAML codegen would
generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`,
`NavigationRootManager.cs`), which macOS can't run.
- Negative controls prove the changed files are compiled. Injecting `int
x = "x";` produced CS0029 in `ShadowExtensions.cs`,
`ShapesExtensions.cs` and `WrapperView.cs`. The controls were then
reverted.
- `dotnet format whitespace --folder --verify-no-changes --include <3
changed files>`: **passed**.
- **Not run locally:** I have no Windows host, so the Windows runtime
legs (fix green, fix reverted red, restored green) couldn't be produced
locally. This PR's CI has to show them: `maui-pr-devicetests` Windows
Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests`
Windows BoxView/Shadow snapshots. Those snapshots include #40175's
`BoxView_*AndShadow` baselines, which have not been changed here.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow:
true)` regression found while validating #40116. It keeps the
shape-following shadow fix for #31821.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

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
…ed shapes (#40349)

<!-- 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 repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

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

**Regression.** The Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0,
hasShadow: true)` fails deterministically on net11 and on the candidate
with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`.
- The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the
candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the
next build, 1680671 (`ea39223fd0`), failed.
- #40175's only product change is in `ShadowExtensions.cs`. For a
`W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask
with a live `CompositionVisualSurface` whose `SourceVisual` is the
element's own visual.
- With that surface attached, the shape's content is missing from
`RenderTargetBitmap` captures. That covers the device test's `RawBitmap`
capture and `CaptureAsync` on Windows. The hasShadow:false rows of the
same theory still capture the Win2D content, so `RenderTargetBitmap`
itself does capture Win2D content.

**Fix** (this keeps #40175's goal from #31821, a shadow that follows the
shape):
- `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable`
into an offscreen Win2D `CanvasRenderTarget` and uses the result as a
static `DropShadow` mask, the same kind of mask other elements get. It
mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI,
the logical-size scale correction and the RTL flip. It doesn't depend on
whether the `CanvasControl` has drawn yet.
- Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and
`ShapesExtensions.InvalidateShape` now call a new internal
`WrapperView.InvalidateShadow()`. It refreshes the mask only when a
shadow exists, so the shadow keeps following shape changes such as
corner radius, aspect or flow direction made after the shadow is set.
Size, shadow and clip changes already refreshed the mask through
`UpdateShadowAsync`.

There are no public API changes, no test changes and no baseline or
tolerance changes.

**Validation**
- Baseline red: the row fails deterministically in net11 and candidate
Windows device builds, starting exactly at #40175, as described above.
- Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj
-p:TargetFrameworks=net11.0-windows10.0.19041.0
-p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true
-p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false
-p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`.
- **Passed** for the changed files: they produced 0 errors. The build
still fails with only the known errors from code that XAML codegen would
generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`,
`NavigationRootManager.cs`), which macOS can't run.
- Negative controls prove the changed files are compiled. Injecting `int
x = "x";` produced CS0029 in `ShadowExtensions.cs`,
`ShapesExtensions.cs` and `WrapperView.cs`. The controls were then
reverted.
- `dotnet format whitespace --folder --verify-no-changes --include <3
changed files>`: **passed**.
- **Not run locally:** I have no Windows host, so the Windows runtime
legs (fix green, fix reverted red, restored green) couldn't be produced
locally. This PR's CI has to show them: `maui-pr-devicetests` Windows
Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests`
Windows BoxView/Shadow snapshots. Those snapshots include #40175's
`BoxView_*AndShadow` baselines, which have not been changed here.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow:
true)` regression found while validating #40116. It keeps the
shape-following shadow fix for #31821.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

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
…ed shapes (#40349)

<!-- 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 repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

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

**Regression.** The Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0,
hasShadow: true)` fails deterministically on net11 and on the candidate
with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`.
- The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the
candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the
next build, 1680671 (`ea39223fd0`), failed.
- #40175's only product change is in `ShadowExtensions.cs`. For a
`W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask
with a live `CompositionVisualSurface` whose `SourceVisual` is the
element's own visual.
- With that surface attached, the shape's content is missing from
`RenderTargetBitmap` captures. That covers the device test's `RawBitmap`
capture and `CaptureAsync` on Windows. The hasShadow:false rows of the
same theory still capture the Win2D content, so `RenderTargetBitmap`
itself does capture Win2D content.

**Fix** (this keeps #40175's goal from #31821, a shadow that follows the
shape):
- `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable`
into an offscreen Win2D `CanvasRenderTarget` and uses the result as a
static `DropShadow` mask, the same kind of mask other elements get. It
mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI,
the logical-size scale correction and the RTL flip. It doesn't depend on
whether the `CanvasControl` has drawn yet.
- Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and
`ShapesExtensions.InvalidateShape` now call a new internal
`WrapperView.InvalidateShadow()`. It refreshes the mask only when a
shadow exists, so the shadow keeps following shape changes such as
corner radius, aspect or flow direction made after the shadow is set.
Size, shadow and clip changes already refreshed the mask through
`UpdateShadowAsync`.

There are no public API changes, no test changes and no baseline or
tolerance changes.

**Validation**
- Baseline red: the row fails deterministically in net11 and candidate
Windows device builds, starting exactly at #40175, as described above.
- Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj
-p:TargetFrameworks=net11.0-windows10.0.19041.0
-p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true
-p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false
-p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`.
- **Passed** for the changed files: they produced 0 errors. The build
still fails with only the known errors from code that XAML codegen would
generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`,
`NavigationRootManager.cs`), which macOS can't run.
- Negative controls prove the changed files are compiled. Injecting `int
x = "x";` produced CS0029 in `ShadowExtensions.cs`,
`ShapesExtensions.cs` and `WrapperView.cs`. The controls were then
reverted.
- `dotnet format whitespace --folder --verify-no-changes --include <3
changed files>`: **passed**.
- **Not run locally:** I have no Windows host, so the Windows runtime
legs (fix green, fix reverted red, restored green) couldn't be produced
locally. This PR's CI has to show them: `maui-pr-devicetests` Windows
Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests`
Windows BoxView/Shadow snapshots. Those snapshots include #40175's
`BoxView_*AndShadow` baselines, which have not been changed here.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow:
true)` regression found while validating #40116. It keeps the
shape-following shadow fix for #31821.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

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
…ed shapes (#40349)

<!-- 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 repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

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

**Regression.** The Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0,
hasShadow: true)` fails deterministically on net11 and on the candidate
with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`.
- The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the
candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the
next build, 1680671 (`ea39223fd0`), failed.
- #40175's only product change is in `ShadowExtensions.cs`. For a
`W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask
with a live `CompositionVisualSurface` whose `SourceVisual` is the
element's own visual.
- With that surface attached, the shape's content is missing from
`RenderTargetBitmap` captures. That covers the device test's `RawBitmap`
capture and `CaptureAsync` on Windows. The hasShadow:false rows of the
same theory still capture the Win2D content, so `RenderTargetBitmap`
itself does capture Win2D content.

**Fix** (this keeps #40175's goal from #31821, a shadow that follows the
shape):
- `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable`
into an offscreen Win2D `CanvasRenderTarget` and uses the result as a
static `DropShadow` mask, the same kind of mask other elements get. It
mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI,
the logical-size scale correction and the RTL flip. It doesn't depend on
whether the `CanvasControl` has drawn yet.
- Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and
`ShapesExtensions.InvalidateShape` now call a new internal
`WrapperView.InvalidateShadow()`. It refreshes the mask only when a
shadow exists, so the shadow keeps following shape changes such as
corner radius, aspect or flow direction made after the shadow is set.
Size, shadow and clip changes already refreshed the mask through
`UpdateShadowAsync`.

There are no public API changes, no test changes and no baseline or
tolerance changes.

**Validation**
- Baseline red: the row fails deterministically in net11 and candidate
Windows device builds, starting exactly at #40175, as described above.
- Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj
-p:TargetFrameworks=net11.0-windows10.0.19041.0
-p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true
-p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false
-p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`.
- **Passed** for the changed files: they produced 0 errors. The build
still fails with only the known errors from code that XAML codegen would
generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`,
`NavigationRootManager.cs`), which macOS can't run.
- Negative controls prove the changed files are compiled. Injecting `int
x = "x";` produced CS0029 in `ShadowExtensions.cs`,
`ShapesExtensions.cs` and `WrapperView.cs`. The controls were then
reverted.
- `dotnet format whitespace --folder --verify-no-changes --include <3
changed files>`: **passed**.
- **Not run locally:** I have no Windows host, so the Windows runtime
legs (fix green, fix reverted red, restored green) couldn't be produced
locally. This PR's CI has to show them: `maui-pr-devicetests` Windows
Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests`
Windows BoxView/Shadow snapshots. Those snapshots include #40175's
`BoxView_*AndShadow` baselines, which have not been changed here.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow:
true)` regression found while validating #40116. It keeps the
shape-following shadow fix for #31821.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

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
…ed shapes (#40349)

<!-- 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 repair for the SR2 candidate (#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

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

**Regression.** The Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0,
hasShadow: true)` fails deterministically on net11 and on the candidate
with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`.
- The onset is #40175 (`ea39223fd0` on net11, `219a32fbcc` on the
candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the
next build, 1680671 (`ea39223fd0`), failed.
- #40175's only product change is in `ShadowExtensions.cs`. For a
`W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask
with a live `CompositionVisualSurface` whose `SourceVisual` is the
element's own visual.
- With that surface attached, the shape's content is missing from
`RenderTargetBitmap` captures. That covers the device test's `RawBitmap`
capture and `CaptureAsync` on Windows. The hasShadow:false rows of the
same theory still capture the Win2D content, so `RenderTargetBitmap`
itself does capture Win2D content.

**Fix** (this keeps #40175's goal from #31821, a shadow that follows the
shape):
- `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable`
into an offscreen Win2D `CanvasRenderTarget` and uses the result as a
static `DropShadow` mask, the same kind of mask other elements get. It
mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI,
the logical-size scale correction and the RTL flip. It doesn't depend on
whether the `CanvasControl` has drawn yet.
- Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and
`ShapesExtensions.InvalidateShape` now call a new internal
`WrapperView.InvalidateShadow()`. It refreshes the mask only when a
shadow exists, so the shadow keeps following shape changes such as
corner radius, aspect or flow direction made after the shadow is set.
Size, shadow and clip changes already refreshed the mask through
`UpdateShadowAsync`.

There are no public API changes, no test changes and no baseline or
tolerance changes.

**Validation**
- Baseline red: the row fails deterministically in net11 and candidate
Windows device builds, starting exactly at #40175, as described above.
- Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj
-p:TargetFrameworks=net11.0-windows10.0.19041.0
-p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true
-p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false
-p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`.
- **Passed** for the changed files: they produced 0 errors. The build
still fails with only the known errors from code that XAML codegen would
generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`,
`NavigationRootManager.cs`), which macOS can't run.
- Negative controls prove the changed files are compiled. Injecting `int
x = "x";` produced CS0029 in `ShadowExtensions.cs`,
`ShapesExtensions.cs` and `WrapperView.cs`. The controls were then
reverted.
- `dotnet format whitespace --folder --verify-no-changes --include <3
changed files>`: **passed**.
- **Not run locally:** I have no Windows host, so the Windows runtime
legs (fix green, fix reverted red, restored green) couldn't be produced
locally. This PR's CI has to show them: `maui-pr-devicetests` Windows
Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests`
Windows BoxView/Shadow snapshots. Those snapshots include #40175's
`BoxView_*AndShadow` baselines, which have not been changed here.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow:
true)` regression found while validating #40116. It keeps the
shape-following shadow fix for #31821.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

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
…ed shapes (dotnet#40349)

<!-- 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 repair for the SR2 candidate (dotnet#40116), so it targets
`candidate/11.0.1xx-sr2` as assigned.

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

**Regression.** The Windows device test
`BorderTests.BorderClipsTransformedContentToItsShape(3, 0, 0, 0,
hasShadow: true)` fails deterministically on net11 and on the candidate
with `pixel (50,50) expected red, was (0,0,0,0)`. It passes on `main`.
- The onset is dotnet#40175 (`ea39223fd0` on net11, `219a32fbcc` on the
candidate). net11 device build 1680463 (`b2d31412a9`) passed, and the
next build, 1680671 (`ea39223fd0`), failed.
- dotnet#40175's only product change is in `ShadowExtensions.cs`. For a
`W2DGraphicsView` with a `ShapeDrawable`, it replaced the static mask
with a live `CompositionVisualSurface` whose `SourceVisual` is the
element's own visual.
- With that surface attached, the shape's content is missing from
`RenderTargetBitmap` captures. That covers the device test's `RawBitmap`
capture and `CaptureAsync` on Windows. The hasShadow:false rows of the
same theory still capture the Win2D content, so `RenderTargetBitmap`
itself does capture Win2D content.

**Fix** (this keeps dotnet#40175's goal from dotnet#31821, a shadow that follows the
shape):
- `ShadowExtensions.GetShapeAlphaMask` draws the view's `ShapeDrawable`
into an offscreen Win2D `CanvasRenderTarget` and uses the result as a
static `DropShadow` mask, the same kind of mask other elements get. It
mirrors `W2DGraphicsView.OnDraw`: it uses the rasterization-scale DPI,
the logical-size scale correction and the RTL flip. It doesn't depend on
whether the `CanvasControl` has drawn yet.
- Because the mask is a snapshot, `ShapesExtensions.UpdateShape` and
`ShapesExtensions.InvalidateShape` now call a new internal
`WrapperView.InvalidateShadow()`. It refreshes the mask only when a
shadow exists, so the shadow keeps following shape changes such as
corner radius, aspect or flow direction made after the shadow is set.
Size, shadow and clip changes already refreshed the mask through
`UpdateShadowAsync`.

There are no public API changes, no test changes and no baseline or
tolerance changes.

**Validation**
- Baseline red: the row fails deterministically in net11 and candidate
Windows device builds, starting exactly at dotnet#40175, as described above.
- Windows TFM compile on macOS: `dotnet build src/Core/src/Core.csproj
-p:TargetFrameworks=net11.0-windows10.0.19041.0
-p:IncludeWindowsTargetFrameworks=true -p:EnableWindowsTargeting=true
-p:AppxGeneratePriEnabled=false -p:GenerateLibraryLayout=false
-p:EnableDefaultPageItems=false -p:EnableDefaultXamlItems=false`.
- **Passed** for the changed files: they produced 0 errors. The build
still fails with only the known errors from code that XAML codegen would
generate (`MauiToolbar.xaml.cs`, `RootNavigationView.cs`,
`NavigationRootManager.cs`), which macOS can't run.
- Negative controls prove the changed files are compiled. Injecting `int
x = "x";` produced CS0029 in `ShadowExtensions.cs`,
`ShapesExtensions.cs` and `WrapperView.cs`. The controls were then
reverted.
- `dotnet format whitespace --folder --verify-no-changes --include <3
changed files>`: **passed**.
- **Not run locally:** I have no Windows host, so the Windows runtime
legs (fix green, fix reverted red, restored green) couldn't be produced
locally. This PR's CI has to show them: `maui-pr-devicetests` Windows
Border (`BorderClipsTransformedContentToItsShape`) and `maui-pr-uitests`
Windows BoxView/Shadow snapshots. Those snapshots include dotnet#40175's
`BoxView_*AndShadow` baselines, which have not been changed here.

### Issues Fixed

Fixes the Windows `BorderClipsTransformedContentToItsShape(hasShadow:
true)` regression found while validating dotnet#40116. It keeps the
shape-following shadow fix for dotnet#31821.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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 — b387f83d Deployed Nov 17, 2026 by kubaflo via conclusion #3054
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants