Skip to content

[Windows] Fix Boxview shadow is not aligned with box view shape - #40175

Merged
kubaflo merged 3 commits into
dotnet:net11from
SubhikshaSf4851:Fix-31821
Nov 13, 2026
Merged

kubaflo merged 3 commits into
dotnet:net11from
SubhikshaSf4851:Fix-31821

Conversation

@SubhikshaSf4851

Copy link
Copy Markdown
Contributor

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

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

This pull request primarily improves shadow rendering support for Win2D-based shapes on Windows and updates test conditions related to shadow features. The most significant changes are the addition of logic to handle W2DGraphicsView with ShapeDrawable in shadow rendering, as well as updates to test preprocessor directives and references.

Shadow rendering improvements:

  • ShadowExtensions.cs: Added logic in GetAlphaMaskAsync to handle W2DGraphicsView with ShapeDrawable, using the live visual for shadow rendering since RenderTargetBitmap cannot capture Win2D content.
  • ShadowExtensions.cs: Added necessary using directives for Microsoft.Maui.Graphics.Win2D and aliased ShapeDrawable for clarity. [1] [2]

Test updates:

  • ShadowFeatureTests.cs: Updated the Windows shadow test exclusion to reference the correct GitHub issue (40172 instead of 27732).
  • BoxViewFeatureTests.cs: Removed the preprocessor directive that disabled shadow tests on Windows, re-enabling those tests. [1] [2]

Issues Fixed

Fixes #31821

Tested the behavior in the following platforms

  • Windows
  • Android
  • iOS
  • Mac
Before Issue Fix After Issue Fix
BeforeFix1821 AfterFix31821

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

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

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

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Nov 12, 2026
@azure-pipelines

This comment has been minimized.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 12, 2026
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added platform/windows area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing labels Nov 12, 2026
@vishnumenon2684

This comment has been minimized.

@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 12, 2026
@MauiBot

MauiBot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@SubhikshaSf4851 — 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 12, 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 — 1 finding

Reviewed commit 562b72c.

See inline comments for details.

@kubaflo

This comment has been minimized.

@kubaflo

kubaflo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

/rebase

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

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

kubaflo added a commit that referenced this pull request Nov 17, 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>
marcelomoresco pushed a commit to marcelomoresco/dotnet-maui that referenced this pull request Nov 18, 2026
…et#40175)

<!--
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 |

- [ ] 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).

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
This pull request primarily improves shadow rendering support for
Win2D-based shapes on Windows and updates test conditions related to
shadow features. The most significant changes are the addition of logic
to handle `W2DGraphicsView` with `ShapeDrawable` in shadow rendering, as
well as updates to test preprocessor directives and references.

**Shadow rendering improvements:**

*
[`ShadowExtensions.cs`](diffhunk://#diff-6c904999b229ffd792f069a6a0ddaf850a67a046624c4e915b57ece230ca9a09R43-R51):
Added logic in `GetAlphaMaskAsync` to handle `W2DGraphicsView` with
`ShapeDrawable`, using the live visual for shadow rendering since
`RenderTargetBitmap` cannot capture Win2D content.
*
[`ShadowExtensions.cs`](diffhunk://#diff-6c904999b229ffd792f069a6a0ddaf850a67a046624c4e915b57ece230ca9a09R7):
Added necessary using directives for `Microsoft.Maui.Graphics.Win2D` and
aliased `ShapeDrawable` for clarity.
[[1]](diffhunk://#diff-6c904999b229ffd792f069a6a0ddaf850a67a046624c4e915b57ece230ca9a09R7)
[[2]](diffhunk://#diff-6c904999b229ffd792f069a6a0ddaf850a67a046624c4e915b57ece230ca9a09R16)

**Test updates:**

*
[`ShadowFeatureTests.cs`](diffhunk://#diff-560f9cb1cec21af3a1c6ae51a0b30849aea0f019d519990a0b24dba91971d67fL218-R218):
Updated the Windows shadow test exclusion to reference the correct
GitHub issue (`40172` instead of `27732`).
*
[`BoxViewFeatureTests.cs`](diffhunk://#diff-3455b54055dcfe7c51234f9e7cc13af77da827ea7b097f7fe77d44acad4b0f79L163):
Removed the preprocessor directive that disabled shadow tests on
Windows, re-enabling those tests.
[[1]](diffhunk://#diff-3455b54055dcfe7c51234f9e7cc13af77da827ea7b097f7fe77d44acad4b0f79L163)
[[2]](diffhunk://#diff-3455b54055dcfe7c51234f9e7cc13af77da827ea7b097f7fe77d44acad4b0f79L235)
<!-- Enter description of the fix in this section -->

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes dotnet#31821 

### Tested the behavior in the following platforms
- [x] Windows
- [ ] Android
- [ ] iOS
- [ ] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="998" height="944" alt="BeforeFix1821"
src="https://github.com/user-attachments/assets/b4a526d3-a615-4fea-9ede-55129e23314e"
/> | <img width="1259" height="952" alt="AfterFix31821"
src="https://github.com/user-attachments/assets/17282ba8-85cb-48a0-814b-beac7642c7b6"
/> |
<!--
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: Jakub Florkowski <kubaflo123@gmail.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
…orm (#40365)

Issue Details:
In #40175, the BoxView shadow rendering was updated on
Windows to use the live composition visual for Win2D-based shapes
instead of relying on RenderTargetBitmap. This affected the existing
clipping test introduced in #37424, which used pixel
assertions to verify that transformed BoxView content remained clipped
to the Border's shape. Since RenderTargetBitmap does not reliably
capture Win2D content, the test became unreliable.
 
Description of Changes:
Updated the clipping test introduced in #37424 to avoid
screenshot-based pixel assertions affected by #40175. The
test now verifies that the Border creates a ContentPanelClipHost, that
its content (including the WrapperView when a shadow is applied) is
hosted inside the clip host, and that the host's composition visual
contains a valid CompositionGeometricClip with a
CompositionPathGeometry. This ensures that transformed content remains
clipped to the Border's shape, with and without shadows.

Fixes: #40116

Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.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
…orm (#40365)

Issue Details:
In #40175, the BoxView shadow rendering was updated on
Windows to use the live composition visual for Win2D-based shapes
instead of relying on RenderTargetBitmap. This affected the existing
clipping test introduced in #37424, which used pixel
assertions to verify that transformed BoxView content remained clipped
to the Border's shape. Since RenderTargetBitmap does not reliably
capture Win2D content, the test became unreliable.
 
Description of Changes:
Updated the clipping test introduced in #37424 to avoid
screenshot-based pixel assertions affected by #40175. The
test now verifies that the Border creates a ContentPanelClipHost, that
its content (including the WrapperView when a shadow is applied) is
hosted inside the clip host, and that the host's composition visual
contains a valid CompositionGeometricClip with a
CompositionPathGeometry. This ensures that transformed content remains
clipped to the Border's shape, with and without shadows.

Fixes: #40116

Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.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 19, 2026
…orm (#40365)

Issue Details:
In #40175, the BoxView shadow rendering was updated on
Windows to use the live composition visual for Win2D-based shapes
instead of relying on RenderTargetBitmap. This affected the existing
clipping test introduced in #37424, which used pixel
assertions to verify that transformed BoxView content remained clipped
to the Border's shape. Since RenderTargetBitmap does not reliably
capture Win2D content, the test became unreliable.
 
Description of Changes:
Updated the clipping test introduced in #37424 to avoid
screenshot-based pixel assertions affected by #40175. The
test now verifies that the Border creates a ContentPanelClipHost, that
its content (including the WrapperView when a shadow is applied) is
hosted inside the clip host, and that the host's composition visual
contains a valid CompositionGeometricClip with a
CompositionPathGeometry. This ensures that transformed content remains
clipped to the Border's shape, with and without shadows.

Fixes: #40116

Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.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 22, 2026
…orm (#40365)

Issue Details:
In #40175, the BoxView shadow rendering was updated on
Windows to use the live composition visual for Win2D-based shapes
instead of relying on RenderTargetBitmap. This affected the existing
clipping test introduced in #37424, which used pixel
assertions to verify that transformed BoxView content remained clipped
to the Border's shape. Since RenderTargetBitmap does not reliably
capture Win2D content, the test became unreliable.
 
Description of Changes:
Updated the clipping test introduced in #37424 to avoid
screenshot-based pixel assertions affected by #40175. The
test now verifies that the Border creates a ContentPanelClipHost, that
its content (including the WrapperView when a shadow is applied) is
hosted inside the clip host, and that the host's composition visual
contains a valid CompositionGeometricClip with a
CompositionPathGeometry. This ensures that transformed content remains
clipped to the Border's shape, with and without shadows.

Fixes: #40116

Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.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 added a commit that referenced this pull request Nov 23, 2026
…orm (#40365)

Issue Details:
In #40175, the BoxView shadow rendering was updated on
Windows to use the live composition visual for Win2D-based shapes
instead of relying on RenderTargetBitmap. This affected the existing
clipping test introduced in #37424, which used pixel
assertions to verify that transformed BoxView content remained clipped
to the Border's shape. Since RenderTargetBitmap does not reliably
capture Win2D content, the test became unreliable.
 
Description of Changes:
Updated the clipping test introduced in #37424 to avoid
screenshot-based pixel assertions affected by #40175. The
test now verifies that the Border creates a ContentPanelClipHost, that
its content (including the WrapperView when a shadow is applied) is
hosted inside the clip host, and that the host's composition visual
contains a valid CompositionGeometricClip with a
CompositionPathGeometry. This ensures that transformed content remains
clipped to the Border's shape, with and without shadows.

Fixes: #40116

Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
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>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…orm (dotnet#40365)

Issue Details:
In dotnet#40175, the BoxView shadow rendering was updated on
Windows to use the live composition visual for Win2D-based shapes
instead of relying on RenderTargetBitmap. This affected the existing
clipping test introduced in dotnet#37424, which used pixel
assertions to verify that transformed BoxView content remained clipped
to the Border's shape. Since RenderTargetBitmap does not reliably
capture Win2D content, the test became unreliable.
 
Description of Changes:
Updated the clipping test introduced in dotnet#37424 to avoid
screenshot-based pixel assertions affected by dotnet#40175. The
test now verifies that the Border creates a ContentPanelClipHost, that
its content (including the WrapperView when a shadow is applied) is
hosted inside the clip host, and that the host's composition visual
contains a valid CompositionGeometricClip with a
CompositionPathGeometry. This ensures that transformed content remains
clipped to the Border's shape, with and without shadows.

Fixes: dotnet#40116

Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants