Skip to content

[Windows] Preserve Button image/text spacing during asynchronous image loading - #40203

Merged
kubaflo merged 1 commit into
candidate/11.0.1xx-sr2from
kubaflo-windows-button-spacing
Nov 13, 2026
Merged

kubaflo merged 1 commit into
candidate/11.0.1xx-sr2from
kubaflo-windows-button-spacing

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Note

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

Target Branch

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

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.

This is the explicitly requested candidate-regression correction for #40116, targeting candidate/11.0.1xx-sr2, not an automatically selected staging target.

Description of Change

Preserve Windows Button image/text spacing when its image loads asynchronously.

DefaultMauiButtonContent previously cached AdjustSpacing(spacing) while mapping ContentLayout. The image is initially collapsed, so an asynchronously loaded image can permanently cache zero spacing. #39911 makes this observable for font images by yielding before rendering to avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing against current image/text visibility during measure and both arrange paths. This restores left/right/top/bottom gaps and continues to omit the gap for image-only or text-only content. The entire production change is confined to src/Core/src/Platform/Windows/MauiButton.cs.

The font-rendering deferral, cancellation checks, and resource disposal from #39911 are unchanged. No mapper callbacks, snapshot updates, tolerances, assertions, retries, timeouts, test filters, or pipeline configuration are changed. There is no public API change.

Native Windows evidence

Validated commit: e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2, based on candidate 08fbadc06fb09ac8072b09e957984234045cbd2d. The candidate head was rechecked before publication.

Unchanged regression oracle Candidate build 1678469 Corrected build 1678597
Issue21202(Windows).Issue21202Test Failed, 4.45% difference, including retry Passed, run 46792972 / result 100202
Issue22433(Windows).ButtonLayoutAndSpacingTests Failed, 2.23% difference, including retry Passed, run 46792972 / result 100048

Corrected native Windows run used the existing pipeline 313 stagesToSkip option to exclude non-Windows stages, not invented test-filter parameters. Both Windows host-app builds succeeded. The unchanged Border,BoxView,Brush,Button shard completed with 219 passed, 2 skipped, 0 failed; its published results contain all 221 results. ButtonLayoutAndSpacingTests exercises the Default, Layout, and Spacing screenshots, including all four image positions and custom spacing.

Raw Azure logs were retrieved through az devops invoke and inspected: Button-shard execution, log 1221, publication, log 1223, and native compilation logs 53/76.

Both focal methods passed in each of the five supplied net11 baseline runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest passing baseline build 1676275 used source e181a663463723a772daf45b4d875c022d066d67. All four Windows snapshot blobs used by these methods are identical between that source, the candidate, and this fix; this is a product correction, not a baseline refresh.

Remaining limitations: the overall corrected Windows run is failed, not green: Issue8308.NavigatingBackToCollectionViewShouldNotCrash still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in each). That independently owned Shell automation-ID repair is deliberately not included. Other platforms were not run for this Windows-only correction. Evidence obtained is candidate red -> one-file fix green; no trigger-removal or fix-reversion/restoration run was performed. Passing focal results have no retained image attachments, so screenshot validation is evidenced by the unchanged native snapshot assertions, not a newly exported after-image.

Local validation: dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet passed; git diff --check passed.

Upstream open/recently merged PR searches for MauiButton, ContentLayout, Button spacing, and asynchronous image spacing found no owning correction to reuse.

Issues Fixed

Relates to #40116. Follows up #39911 without reverting its crash prevention for #39888. Uses the existing #21202 and #22433 regression oracles unchanged.

Keep configured content spacing and resolve image/text visibility during measure and arrange instead of caching zero before an async font image loads.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@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 13, 2026
@kubaflo

kubaflo commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

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

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

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

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

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

No immutable without-fix baseline was prepared.

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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 0 findings

Reviewed commit e9ba65e.

@kubaflo
kubaflo merged commit 61fe8e2 into candidate/11.0.1xx-sr2 Nov 13, 2026
42 of 66 checks passed
@kubaflo
kubaflo deleted the kubaflo-windows-button-spacing branch November 13, 2026 00:33
@kubaflo kubaflo mentioned this pull request Nov 13, 2026
1 task
kubaflo added a commit that referenced this pull request Nov 13, 2026
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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 16, 2026
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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 16, 2026
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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 17, 2026
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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
…e loading (#40203)

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

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.

This is the explicitly requested candidate-regression correction for
#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. #39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from #39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to #40116. Follows up #39911 without reverting its crash
prevention for #39888. Uses the existing #21202 and #22433 regression
oracles unchanged.

<!--
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 kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…e loading (dotnet#40203)

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

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.

This is the explicitly requested candidate-regression correction for
dotnet#40116, targeting `candidate/11.0.1xx-sr2`, not an automatically
selected staging target.

### Description of Change

<!-- Enter description of the fix in this section -->

Preserve Windows Button image/text spacing when its image loads
asynchronously.

`DefaultMauiButtonContent` previously cached `AdjustSpacing(spacing)`
while mapping `ContentLayout`. The image is initially collapsed, so an
asynchronously loaded image can permanently cache zero spacing. dotnet#39911
makes this observable for font images by yielding before rendering to
avoid WinUI layout/STA reentrancy.

Store the configured spacing unchanged, then resolve effective spacing
against current image/text visibility during measure and both arrange
paths. This restores left/right/top/bottom gaps and continues to omit
the gap for image-only or text-only content. The entire production
change is confined to `src/Core/src/Platform/Windows/MauiButton.cs`.

The font-rendering deferral, cancellation checks, and resource disposal
from dotnet#39911 are unchanged. No mapper callbacks, snapshot updates,
tolerances, assertions, retries, timeouts, test filters, or pipeline
configuration are changed. There is no public API change.

#### Native Windows evidence

Validated commit: `e9ba65ec8c1d53f2c01457fa622e46e2bfda69e2`, based on
candidate `08fbadc06fb09ac8072b09e957984234045cbd2d`. The candidate head
was rechecked before publication.

| Unchanged regression oracle | Candidate build 1678469 | Corrected
build 1678597 |
| --- | --- | --- |
| `Issue21202(Windows).Issue21202Test` | Failed, 4.45% difference,
including retry | Passed, run 46792972 / result 100202 |
| `Issue22433(Windows).ButtonLayoutAndSpacingTests` | Failed, 2.23%
difference, including retry | Passed, run 46792972 / result 100048 |

[Corrected native Windows
run](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1678597)
used the existing pipeline 313 `stagesToSkip` option to exclude
non-Windows stages, not invented test-filter parameters. Both Windows
host-app builds succeeded. The unchanged `Border,BoxView,Brush,Button`
shard completed with **219 passed, 2 skipped, 0 failed**; its [published
results](https://dev.azure.com/dnceng-public/public/_TestManagement/Runs?runId=46792972&_a=runCharts)
contain all 221 results. `ButtonLayoutAndSpacingTests` exercises the
Default, Layout, and Spacing screenshots, including all four image
positions and custom spacing.

Raw Azure logs were retrieved through `az devops invoke` and inspected:
[Button-shard execution, log
1221](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1221),
[publication, log
1223](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1678597/logs/1223),
and native compilation logs 53/76.

Both focal methods passed in each of the five supplied `net11` baseline
runs: 46719362, 46602928, 46587802, 46581236, and 46559036. The latest
passing baseline build 1676275 used source
`e181a663463723a772daf45b4d875c022d066d67`. All four Windows snapshot
blobs used by these methods are identical between that source, the
candidate, and this fix; this is a product correction, not a baseline
refresh.

**Remaining limitations:** the overall corrected Windows run is failed,
not green: `Issue8308.NavigatingBackToCollectionViewShouldNotCrash`
still fails in CV1 and CV2 (runs 46792350 and 46791982, result 100048 in
each). That independently owned Shell automation-ID repair is
deliberately not included. Other platforms were not run for this
Windows-only correction. Evidence obtained is candidate red -> one-file
fix green; no trigger-removal or fix-reversion/restoration run was
performed. Passing focal results have no retained image attachments, so
screenshot validation is evidenced by the unchanged native snapshot
assertions, not a newly exported after-image.

Local validation: `dotnet format Microsoft.Maui.sln --no-restore
--exclude Templates/src --exclude-diagnostics CA1822 --include
src/Core/src/Platform/Windows/MauiButton.cs --verbosity quiet` passed;
`git diff --check` passed.

Upstream open/recently merged PR searches for `MauiButton`,
`ContentLayout`, Button spacing, and asynchronous image spacing found no
owning correction to reuse.

### 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. -->

Relates to dotnet#40116. Follows up dotnet#39911 without reverting its crash
prevention for dotnet#39888. Uses the existing dotnet#21202 and dotnet#22433 regression
oracles unchanged.

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

This branch was previously deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants