Skip to content

[Forward fixes] net11 to main - #40577

Merged
kubaflo merged 210 commits into
mainfrom
net11
Nov 24, 2026
Merged

kubaflo merged 210 commits into
mainfrom
net11

Conversation

@kubaflo

@kubaflo kubaflo commented Nov 24, 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.

Description of Change

Manually forward net11 to main, including the SR2 candidate integration and subsequent changes. Both branches currently use .NET 11; this PR is intentionally opened before the automated forward workflow's .NET 12 gate. It replaces #40576 and uses the live net11 branch as its head, so new net11 commits appear automatically.

At creation, net11 was 5a03607dade32bb138c5fc81ac846bd8cfa9ec82 and main was 59d49f94d2197216d1762cb219dbf00985f49802. The proposed merge changes 638 files, updates the patch version from 11.0.20 to 11.0.30, and changes SDK and dependency versions. Review the full current diff before merging.

Branch safety: GitHub automatic head-branch deletion is enabled for this repository and net11 currently has no branch protection or rules. Ensure net11 cannot be deleted automatically before merging this PR. Unlike the automated workflow, this PR uses the actual servicing branch as its head.

Validation

  • git merge-tree --write-tree 59d49f94d2197216d1762cb219dbf00985f49802 5a03607dade32bb138c5fc81ac846bd8cfa9ec82 - passed without conflicts for the creation snapshots.
  • Local build and tests were not run. Required review and CI must validate the current integration before a maintainer merges it.

Issues Fixed

N/A - forward integration of changes already reviewed on net11.

kubaflo and others added 30 commits November 23, 2026 22:14
…path (APT2260) (#40406)

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

### Description of Change

Build infrastructure only; no product or test code changes.

**Symptom.** Windows `Pack` (and occasionally `Build`) jobs fail
intermittently with `APT2260` in `Controls.Xaml` `net11.0-android37.0`
`Aapt2Link`: `style attribute 'attr/colorPrimary' not found` and other
Material attributes. Recent examples are net11 maui-pr
[1688582](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688582)
and candidate maui-pr
[1688577](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688577).
There have been 6 Pack and 2 Build Windows failures since 15 Nov, across
branches.

**Root cause.** `eng/Build.props` restores
`Microsoft.Maui.BuildTasks.slnf` with `BuildTaskOnlyBuild=true` first,
then the full solution filter, in the same MSBuild process:
1. Under CI, `BuildTaskOnlyBuild=true` disables the all-TFM group in
`Directory.Build.props`. The first restore therefore writes a reduced
`artifacts/obj/<project>/<project>.csproj.nuget.g.props/targets`, with
import groups only for `netstandard2.0`, `netstandard2.1` and `net11.0`.
2. The full restore's evaluations parse those same files into the
in-process `ProjectRootElementCache`, then rewrite them with all TFMs.
3. That cache does not revalidate timestamps: it is created with
`autoReloadFromDisk: false`, keeps 200 strong MRU entries and holds the
rest weakly. Later build evaluations can reuse the stale reduced XML, so
platform TFMs lose their `buildTransitive` package imports, including
the Material `AndroidAarLibrary` items. That produces `APT2260`. Whether
the stale entry survives depends on cache eviction and GC, which is why
the failure is intermittent.

CI binlogs show this directly. In failing build 1688582, the build-phase
evaluations of `Controls.Xaml` (ios/android/windows), `Controls.Core`
(ios/windows) and `Graphics` (android/windows) have zero package imports
from the `nuget.g.targets`. Passing net11 build
[1687936](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1687936)
has the normal import counts. #39779 serialized the two restores
(`RestoreInParallel=false`) but they still shared these generated files.
#40206 worked around the same mechanism for `Controls.Core` with
explicit package references.

**Fix.** For the build-task restore only, `Directory.Build.props` sets
`MSBuildProjectExtensionsPath` to
`$(BaseIntermediateOutputPath)buildtasks\`, so that restore writes
`nuget.g.*`, `project.assets.json` and dgspec files under
`artifacts/obj/<project>/buildtasks/`. The full restore and build keep
the default `artifacts/obj/<project>/` path, and the full restore's
evaluations never read the reduced files. Arcade's `ProjectLayout.props`
sets only `BaseIntermediateOutputPath`, and `Microsoft.Common.props`
defaults `MSBuildProjectExtensionsPath` after importing
`Directory.Build.props`, so this is the supported place to set it.
Nothing in the repo reads these paths directly. Other
`BuildTaskOnlyBuild` callers (`eng/cake/dotnet.cake`,
`eng/pipelines/arcade/setup-test-env.yml`) restore before every later
build, so they also stop overwriting the full assets. The comment in
`eng/Build.props` is updated to match.

Rejected alternatives:
- `MSBUILDNOINPROCNODE=1`: pipeline-wide behaviour change.
- More explicit package references, as in #40206: a per-project
workaround that doesn't remove the shared state.
- Disabling project-extension imports: unsafe.

### Validation

All runs used SDK 11.0.100 with `dotnet msbuild -m:1 -nodeReuse:false`.

**Minimal standalone repro.** A local package with `build/net10.0`
targets, consumed by a library whose TFMs shrink from `net11.0;net10.0`
to `net11.0` under `BuildTaskOnlyBuild=true`. The driver runs the
reduced restore, then the full restore, then reads the package marker
for `net10.0`:

| Run | Result |
| --- | --- |
| Baseline | marker missing (red) |
| Fix | marker present (green) |
| Fix reverted | marker missing (red) |
| Fix restored | marker present (green) |
| Control: baseline with `MSBUILDNOINPROCNODE=1` | marker present
(green): the in-proc XML cache is the mechanism |

**Repo-level repro, in Arcade's order.** The driver runs a
`BuildTasks.slnf` restore with `BuildTaskOnlyBuild=true`, then a full
`Controls.Xaml` restore, then an evaluation of `Controls.Xaml`
`net11.0-android37.0` that counts `AndroidAarLibrary` items. All runs
used `CI=true -p:IncludeMacOSTargetFrameworks=false`.
`MSBUILDPROJECTROOTELEMENTCACHESIZE=100000` stops strong-cache eviction,
which makes the CI intermittency deterministic:

| Run | AndroidAarLibrary (all / Material) | Package imports in the
build-phase android evaluation |
| --- | --- | --- |
| Baseline | 0 / 0 (red) | 31: the stale reduced `nuget.g.targets` |
| Fix | 69 / 1 (green) | 133 |
| Fix reverted | 0 / 0 (red) | — |
| Fix restored | 69 / 1 (green) | — |

With default cache settings the baseline was green locally (69/1), which
is consistent with the eviction-dependent intermittency seen in CI.

**Other checks.**
- Evaluation with `BuildTaskOnlyBuild=true`:
`MSBuildProjectExtensionsPath`, `RestoreOutputPath` and
`ProjectAssetsFile` point at `artifacts/obj/Controls.Xaml/buildtasks/`.
Without it they stay at `artifacts/obj/Controls.Xaml/`.
- `CI=true dotnet build Microsoft.Maui.BuildTasks.slnf -c Debug
-p:BuildTaskOnlyBuild=true -p:IncludeMacOSTargetFrameworks=false`: build
succeeded, 0 warnings. All 12 restored projects wrote their assets under
`artifacts/obj/<project>/buildtasks/`.

The CI proof will be a Pack run's Windows binlog: the full restore's
evaluations should no longer import a normal-path `nuget.g.targets`
written by the build-task restore.

### Issues Fixed

Intermittent Windows Pack/Build `APT2260` failures in maui-pr. No issue
is filed; this was found while triaging #40116 CI.

Fixes #

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

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

### Description of Change

Test-only. On Android, `App.DismissKeyboard()` calls Appium's
`hideKeyboard`. That sends ESC, and if the IME is still reported as
shown about a second later, it also sends BACK. When the IME hide takes
longer than that, BACK closes the test page's `MainActivity` and the
launcher comes to the front. The next element lookup then throws a
`NullReferenceException` or times out.

This is the same mechanism as #40361 (Issue35119). There, BACK cancelled
a prompt.

The fix replaces the three Android `DismissKeyboard()` calls in
`Issue28986_ContentPage` (`SafeAreaPerEdgeValidation`,
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`) and
`Issue28986.SafeAreaPerEdgeValidation` with a helper:
- It waits for the keyboard to show.
- It sends only ESC, which the visible IME consumes.
- It asserts that the keyboard hides.

iOS still calls `DismissKeyboard()`. No assertions, tolerances or
baselines change. The keyboard tests in
`Issue28986_SafeAreaBorderOrientation` are excluded on Android
(`TEST_FAILS_ON_ANDROID`), so they are unchanged.

**CI evidence.** Candidate UI 1689104, SafeAreaEdges API36 (log 2836):
- The original attempt hit an NRE in `Tap("GridResetAllButton")` at line
156, right after `DismissKeyboard()` and a passing
`WaitForKeyboardToHide()`.
- Logcat shows ESC to Gboard, then the app's `onRequestHide`, then
`onHidden` after a stalled IME dump. Then a `Transition CLOSE` for the
app task brings the launcher to the front.
- The same NRE@156 signature appears in UI builds 1687709 and 1687330.

**Local causal validation.** Android 16 (API 36) emulator, `net11`
Material3 HostApp APK from UI build 1688901, filter
`Name=SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle|Name=SafeAreaPerEdgeValidation`
(3 tests per run):

| Phase | Runs | Failed tests |
| --- | --- | --- |
| Baseline (`net11`) | 3 | 9/9 |
| Fixed | 3 | 1/9 |
| Fix reverted | 3 | 6/9 |
| Fix restored | 3 | 1/9 |

- Baseline failures match CI: NRE at `Issue28986_ContentPage.cs:156`
(4), timeout at line 105 (4), a failure at line 126 (1), and timeout in
`Issue28986.cs` at line 193 (6). Each comes after ESC, then `onHidden`,
then a mid-test `Transition CLOSE` of the uitests task. The app
relaunches only after the timeout.
- Both fixed-run failures are in
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` at line 121. That is
the earlier "keyboard shown" assertion, before any hide. Logcat shows no
`onRequestShow` in those runs, so the keyboard was never requested. This
is a separate, pre-hide failure that this PR doesn't address.

### Issues Fixed

Fixes CI flakiness in
`Issue28986_ContentPage.SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`,
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` and
`Issue28986.SafeAreaPerEdgeValidation` on Android.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This pull request updates the following dependencies

[marker]: <> (Begin:fc4a0e63-cc9b-414d-9375-11dd045dcfa9)
## From https://github.com/dotnet/android
- **Subscription**:
[fc4a0e63-cc9b-414d-9375-11dd045dcfa9](https://maestro.dot.net/subscriptions?search=fc4a0e63-cc9b-414d-9375-11dd045dcfa9)
- **Build**:
[11.0.1xx-d644ae60c9c7cff27a9813663298c3aa642534a3-1](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=16070009)
([342149](https://maestro.dot.net/channel/8298/github:dotnet:android/build/342149))
- **Date Produced**: November 18, 2026 9:02:56 PM UTC
- **Commit**:
[d644ae60c9c7cff27a9813663298c3aa642534a3](dotnet/android@d644ae6)
- **Branch**:
[release/11.0.1xx](https://github.com/dotnet/android/tree/release/11.0.1xx)

[DependencyUpdate]: <> (Begin)

- **Dependency Updates**:
  - From [37.2.40 to 37.2.43][1]
     - Microsoft.Android.Sdk.Windows

[1]: dotnet/android@37b3691...d644ae6

[DependencyUpdate]: <> (End)


[marker]: <> (End:fc4a0e63-cc9b-414d-9375-11dd045dcfa9)



[marker]: <> (Begin:0340b3ac-0154-4d65-98b8-f534ebc24108)
## From https://github.com/dotnet/dotnet
- **Subscription**:
[0340b3ac-0154-4d65-98b8-f534ebc24108](https://maestro.dot.net/subscriptions?search=0340b3ac-0154-4d65-98b8-f534ebc24108)
- **Build**:
[20261117.5](https://dev.azure.com/dnceng/internal/_build/results?buildId=3138553)
([342028](https://maestro.dot.net/channel/8298/github:dotnet:dotnet/build/342028))
- **Date Produced**: November 18, 2026 7:22:18 AM UTC
- **Commit**:
[81e781b0429cbad5d1984bce95e451bba6aeab0e](dotnet/dotnet@81e781b)
- **Branch**:
[release/11.0.1xx](https://github.com/dotnet/dotnet/tree/release/11.0.1xx)

[DependencyUpdate]: <> (Begin)

- **Dependency Updates**:
  - From [11.0.1 to 11.0.1][2]
     - Microsoft.AspNetCore.Authentication.Facebook
     - Microsoft.AspNetCore.Authentication.Google
     - Microsoft.AspNetCore.Authentication.MicrosoftAccount
     - Microsoft.AspNetCore.Authorization
     - Microsoft.AspNetCore.Components
     - Microsoft.AspNetCore.Components.Analyzers
     - Microsoft.AspNetCore.Components.Forms
     - Microsoft.AspNetCore.Components.Web
     - Microsoft.AspNetCore.Components.WebAssembly
     - Microsoft.AspNetCore.Components.WebAssembly.Server
     - Microsoft.AspNetCore.Components.WebView
     - Microsoft.AspNetCore.Metadata
     - Microsoft.Extensions.Configuration
     - Microsoft.Extensions.Configuration.Abstractions
     - Microsoft.Extensions.Configuration.Json
     - Microsoft.Extensions.DependencyInjection
     - Microsoft.Extensions.DependencyInjection.Abstractions
     - Microsoft.Extensions.FileProviders.Abstractions
     - Microsoft.Extensions.Hosting.Abstractions
     - Microsoft.Extensions.Logging
     - Microsoft.Extensions.Logging.Abstractions
     - Microsoft.Extensions.Logging.Console
     - Microsoft.Extensions.Logging.Debug
     - Microsoft.Extensions.Primitives
     - Microsoft.JSInterop
     - Microsoft.NETCore.App.Ref
  - From [11.0.0-beta.26566.116 to 11.0.0-beta.26567.105][2]
     - Microsoft.DotNet.Arcade.Sdk
     - Microsoft.DotNet.Build.Tasks.Feed
     - Microsoft.DotNet.Build.Tasks.Installers
     - Microsoft.DotNet.Build.Tasks.Workloads
     - Microsoft.DotNet.Helix.JobMonitor
     - Microsoft.DotNet.Helix.Sdk
     - Microsoft.DotNet.RemoteExecutor
     - Microsoft.DotNet.SharedFramework.Sdk
     - Microsoft.DotNet.XUnitExtensions
- From [11.0.101-servicing.26566.116 to 11.0.101-servicing.26567.105][2]
     - Microsoft.NET.Sdk

[2]: dotnet/dotnet@f41eb11...81e781b

[DependencyUpdate]: <> (End)


[marker]: <> (End:0340b3ac-0154-4d65-98b8-f534ebc24108)

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
…r/DragLeave (#40441)

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

### Description of Change

On iOS, `DragEventArgs.GetPosition()` can throw a
`NullReferenceException` inside a `DragOver` or `DragLeave` handler. The
exception crashes the app.

**CI evidence.** The `DropEventCoordinates` UI test crashed the HostApp
on both attempts on the iOS CoreCLR lane of SR2 candidate #40116
(maui-pr-uitests
[1690394](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1690394),
iOS latest Editor..Fr job). The job's `.ips` reports show SIGABRT from
`xamarin_process_managed_exception` under `-[UIDropInteraction
_dragDestinationGestureStateChanged:]`. The logarchive shows the managed
exception:

```
System.NullReferenceException
  at DragAndDropDelegate.CalculatePosition(IElement, WeakReference, WeakReference)
  at DragAndDropBetweenLayouts.OnDragOver(...)        // HostApp calls e.GetPosition(...)
  at DragAndDropDelegate.<HandleDragOver>...
  at DragAndDropDelegate.SendEventArgs(...)
  at DragAndDropDelegate.HandleDragOver(...)
  at DragAndDropDelegate.SessionDidUpdate(...)
```

**Root cause.**
- `SessionDidUpdate` and `SessionDidExit` pass
`session.LocalDragSession`, a transient managed wrapper of the native
local drag session, into `HandleDragOver` and `HandleDragLeave`.
- Those methods put only a `WeakReference` to it in the `GetPosition`
callback, and nothing else on the path keeps it alive:
`PlatformDragEventArgs` holds the outer `IUIDropSession`, not the local
drag session.
- A GC while the user's handler is running can therefore collect the
wrapper. `CalculatePosition` then calls `LocationInView` on a null
session.
- Separately, `HandleDragOver` built a weak reference even when
`LocalDragSession` is null (a drag from another app), so `GetPosition`
always threw in that case. `HandleDragLeave` and `HandleDrop` already
return null there.

The weak references date from 2023, and the code is identical on
`net11`, the candidate and `main`. This is a latent bug that the CoreCLR
lane's GC timing exposed, not a candidate regression.

**Fix** (`DragAndDropDelegate.cs`, iOS/Mac Catalyst):
- `HandleDragOver` and `HandleDragLeave` call `GC.KeepAlive(session)`
after dispatching to the recognizers. The session stays alive while
handlers can synchronously call `GetPosition`, and the event args still
don't hold it strongly.
- `HandleDragOver` uses a null `sessionRef` when there is no local drag
session, matching `HandleDragLeave` and `HandleDrop`.
- `CalculatePosition` returns `null` when the session reference is
missing or its target has already been collected, instead of
dereferencing null. This covers a `GetPosition` call made after the
handler returns.

**Tests** (`DragAndDropTests.iOS.cs`, `Gesture` category):
- `DragPositionIsAvailableAfterGarbageCollectionDuringHandler(dragLeave:
false/true)`: a fake drop session returns a fresh local drag session
wrapper each time, the handler forces a full GC and then calls
`GetPosition`, and the test asserts the fake session's location.
- `DragOverPositionIsNullWithoutLocalDragSession`: with no local drag
session, `GetPosition` in `DragOver` returns `null`.

**Validation** (iOS 18.5 simulator, Release, CoreCLR, the same runtime
as the failing CI lane):

| Command | Result |
| --- | --- |
| `pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1
-Project Controls -Platform ios -TestFilter "Category=Gesture"
-DeviceUdid <iOS 18.5 sim> -SkipXcodeVersionCheck` with only the new
tests (no fix) | **Failed**: 45 passed, 3 failed. All three new cases
throw `NullReferenceException` at
`DragAndDropDelegate.CalculatePosition`, the same frame as the CI crash.
|
| Same command with the fix | **Passed**: 48 passed, 0 failed |
| `dotnet format whitespace --folder --include <changed files>
--verify-no-changes` | Passed |

The UI test itself was not rerun locally, because its crash depends on
when a GC happens.

### Issues Fixed

No existing issue; found while investigating SR2 candidate #40116 CI.
Searched for related issues and PRs and found no duplicate.
#28416/#28417 is an unrelated Mac Catalyst `DragAndDropDelegate` NRE.

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

This pull request updates the following dependencies

[marker]: <> (Begin:f4928934-9e75-4ba7-b3d0-757a5edf906c)
- **Subscription**:
[f4928934-9e75-4ba7-b3d0-757a5edf906c](https://maestro.dot.net/subscriptions?search=f4928934-9e75-4ba7-b3d0-757a5edf906c)
- **Build**:
[20261109.6](https://dev.azure.com/dnceng/internal/_build/results?buildId=3130547)
([340580](https://maestro.dot.net/channel/8298/github:dotnet:dotnet/build/340580))
- **Date Produced**: November 10, 2026 12:07:03 AM UTC
- **Commit**:
[40ce56ee174a4f1914ef78ea848f3198a160e815](dotnet/dotnet@40ce56e)
- **Branch**:
[release/11.0.1xx](https://github.com/dotnet/dotnet/tree/release/11.0.1xx)

[DependencyUpdate]: <> (Begin)

- **Dependency Updates**:
  - From [11.0.0 to 11.0.1][1]
     - Microsoft.AspNetCore.Authentication.Facebook
     - Microsoft.AspNetCore.Authentication.Google
     - Microsoft.AspNetCore.Authentication.MicrosoftAccount
     - Microsoft.AspNetCore.Authorization
     - Microsoft.AspNetCore.Components
     - Microsoft.AspNetCore.Components.Analyzers
     - Microsoft.AspNetCore.Components.Forms
     - Microsoft.AspNetCore.Components.Web
     - Microsoft.AspNetCore.Components.WebAssembly
     - Microsoft.AspNetCore.Components.WebAssembly.Server
     - Microsoft.AspNetCore.Components.WebView
     - Microsoft.AspNetCore.Metadata
     - Microsoft.Extensions.Configuration
     - Microsoft.Extensions.Configuration.Abstractions
     - Microsoft.Extensions.Configuration.Json
     - Microsoft.Extensions.DependencyInjection
     - Microsoft.Extensions.DependencyInjection.Abstractions
     - Microsoft.Extensions.FileProviders.Abstractions
     - Microsoft.Extensions.Hosting.Abstractions
     - Microsoft.Extensions.Logging
     - Microsoft.Extensions.Logging.Abstractions
     - Microsoft.Extensions.Logging.Console
     - Microsoft.Extensions.Logging.Debug
     - Microsoft.Extensions.Primitives
     - Microsoft.JSInterop
     - Microsoft.NETCore.App.Ref
  - From [11.0.0-beta.26555.108 to 11.0.0-beta.26559.106][1]
     - Microsoft.DotNet.Arcade.Sdk
     - Microsoft.DotNet.Build.Tasks.Feed
     - Microsoft.DotNet.Build.Tasks.Installers
     - Microsoft.DotNet.Build.Tasks.Workloads
     - Microsoft.DotNet.Helix.JobMonitor
     - Microsoft.DotNet.Helix.Sdk
     - Microsoft.DotNet.RemoteExecutor
     - Microsoft.DotNet.SharedFramework.Sdk
     - Microsoft.DotNet.XUnitExtensions
  - From [11.0.100-rtm.26555.108 to 11.0.101-servicing.26559.106][1]
     - Microsoft.NET.Sdk

[1]: dotnet/dotnet@1f64ef4...40ce56e

[DependencyUpdate]: <> (End)

[marker]: <> (End:f4928934-9e75-4ba7-b3d0-757a5edf906c)

[marker]: <> (Begin:9a046932-c60c-436e-8fc7-8ea2f5902cb5)
- **Subscription**:
[9a046932-c60c-436e-8fc7-8ea2f5902cb5](https://maestro.dot.net/subscriptions?search=9a046932-c60c-436e-8fc7-8ea2f5902cb5)
- **Build**:
[11.0.1xx-7ff9886196157cc5aea76f227cbf06329629cf6c-1](https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=15967460)
([340520](https://maestro.dot.net/channel/8298/github:dotnet:android/build/340520))
- **Date Produced**: November 9, 2026 7:08:35 PM UTC
- **Commit**:
[7ff9886196157cc5aea76f227cbf06329629cf6c](dotnet/android@7ff9886)
- **Branch**:
[release/11.0.1xx](https://github.com/dotnet/android/tree/release/11.0.1xx)

[DependencyUpdate]: <> (Begin)

- **Dependency Updates**:
  - From [37.2.31 to 37.2.32][2]
     - Microsoft.Android.Sdk.Windows

[2]: dotnet/android@c6663f2...7ff9886

[DependencyUpdate]: <> (End)

[marker]: <> (End:9a046932-c60c-436e-8fc7-8ea2f5902cb5)

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Fixes an infinite loop when synchronizing SelectedIndex and SelectedItem
by only updating SelectedIndex if the value changes. Adds a unit test to
ensure that changing ControlTemplate from SelectedIndexChanged does not
cause recursive events (fixes #8874).

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

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

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
<!-- 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.
-->

### Description of Change

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

Restore custom Shape implementations of `IShape.PathForBounds` when a
renderer requests stroke-aware geometry.

**Regression introduced by**

[PR #37319 — Fix Rectangle Rendering as a Thin Line for Small
Heights](#37319).

The supplied reproduction works on MAUI `10.0.120` and fails on
`10.0.130` on Android and iOS.

**Root cause**

That PR introduced the internal `IShapeWithStroke` interface to
distinguish standalone shape geometry from Border stroke-aware geometry.
Platform renderers were updated to prefer this interface over
`IShape.PathForBounds`.

Custom Shapes inherit `IShapeWithStroke` from `Shape`, even when they
re-implement the public `IShape.PathForBounds` contract. The inherited
stroke-aware implementation directly calls the base path-building
method, bypassing the custom implementation. Applications cannot
re-implement `IShapeWithStroke` because it is internal.

In the reported `FieldShape`, the skipped method initializes the
fallback width and height used to construct the outline. Without that
call, the shape uses incorrect dimensions, producing a malformed outline
instead of the expected rounded border and label gap.

**Fix**

- Dispatch `Shape.IShapeWithStroke.PathForBounds` through
`IShape.PathForBounds`, honoring custom implementations.
- Preserve the requested stroke context for built-in shapes using the
base implementation.
- Save and restore that context with `try`/`finally`, including when
path generation throws.
- Leave RoundRectangle's dedicated implementation unchanged.


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

<!--
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: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40128)

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


### Description of Change

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

Fixes NavigationPage.TitleView being shifted upward and clipped on iOS
26+ when the navigation bar clips its contents.

The full navigation bar can be taller than UIKit's title area. On the
iOS 26.5 reproduction, the bar is 54 pt high while the title area is 44
pt high. Initializing the title container to the full bar height causes
UIKit to position its wrapper at y = -5, clipping the top of the title.

- Initialize the title container using the navigation bar's width and
the title-height fallback, rather than the full bar height.
- In NavigationRenderer, use the attached superview's height instead of
prioritizing the cached navigation-bar height.
- Apply the initial-height correction to NavigationViewHandler as well.
- Preserve the iOS 26 autoresizing-mask workaround and navigation-bar
layout-change tracking.
- Add regression coverage for automatic, short, and tall title views,
exercised against both navigation implementations.

#### Regression origin

The likely introducing change is
[#32798](#32798), the .NET
10 servicing backport of
[#32341](#32341) ("Fix iOS
26 TitleView covering content in Shell and NavigationPage").

[Commit
3218849](3218849)
introduced both the full-bar-height initial frame and the cached
`_navigationBarHeight` preference in `ToolbarHeight`. The change is
absent from MAUI 10.0.10 and present in 10.0.11, matching the [reported
first failing
version](#40068 (comment)).
This attribution is based on source and release ancestry, not a
parent-versus-commit runtime bisect.

This fix retains the autoresizing-mask workaround from that PR; it
corrects the assumption that the title area must have the same height as
the full navigation bar.

#### Before / after

Both screenshots use the same local Sandbox reproduction on an iPhone 17
Pro simulator running **iOS 26.5**, with `UINavigationBar.ClipsToBounds
= true`. "Before" is the unfixed local framework build, not a separate
MAUI 9 package run.

| Before fix — title clipped | After fix — title visible |
| --- | --- |
| <img
src="https://github.com/user-attachments/assets/9c9f4b39-da15-45de-a0e9-71fb96d08687"
alt="Before fix: Czech title clipped at the top; container height 54 pt
and wrapper y minus 5 pt" width="350" /> | <img
src="https://github.com/user-attachments/assets/e42f4c2e-c2e9-4464-92cb-63f516c81112"
alt="After fix: Czech title and diacritics visible; container height 44
pt and wrapper y zero" width="350" /> |

The navigation bar remains 54 pt high in both runs. The title container
changes from **54 pt to 44 pt**, and the wrapper moves from **y = -5 to
y = 0**.

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

<!--
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: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…aries (#40103)

### Description of Change

When a `ResourceDictionary` is inflated at runtime (for example a style
dictionary without code-behind loaded through `Source=`), a
`BasedOn="{StaticResource …}"` lookup can only see resources already
added in that same file, plus application resources that already exist.
A base style living in a sibling merged dictionary is not reachable yet,
so loading the dictionary throws `XamlParseException: StaticResource not
found for key ButtonBaseStyle` and crashes the app at startup. Declaring
a global (implicit) style based on a shared keyed style this way is the
scenario from the issue.

**Fix**

In `StaticResourceExtension.ProvideValue`, when the unresolved target is
`Style.BasedOn` and the XAML root being parsed is a `ResourceDictionary`
(one that is still being loaded), defer the lookup to apply time through
the existing `Style.BaseResourceKey` mechanism instead of throwing. The
base style is then resolved through the consuming element's resource
scope, where the merged dictionaries are available. Failed lookups
anywhere else keep throwing exactly as before.

**Tests**

`Maui24667` (Xaml.UnitTests) inflates a page whose resources merge two
source dictionaries — a keyed `ButtonBaseStyle` and an implicit `Button`
style based on it — plus the issue's implicit-`BaseResourceKey` snippet,
and verifies the base setters are applied. The test runs on all three
inflators (Runtime, XamlC, SourceGen).

| | Without fix | With fix |
|---|---|---|
| Implicit style with `BasedOn="{StaticResource …}"` to a keyed style in
a sibling merged dictionary | `XamlParseException`: StaticResource not
found for key ButtonBaseStyle | Style applied, base setters inherited |
| Implicit style with `BaseResourceKey` (issue snippet) | works | works
|
| Full Xaml.UnitTests + Core.UnitTests | — | No new failures |

### Issues Fixed

Fixes #24667
…osite collection (#40102)

### Description of Change

A `RadioButton` whose `ControlTemplate` comes from an application-level
implicit `Style` renders correctly on iOS but never responds to taps
(#14949; the same mechanism is behind #22377 and #19478).

Because `Application.Current` resources are available as soon as an
element is constructed, the implicit style applies the `ControlTemplate`
while the `RadioButton` is still running its base-class constructors:
`StyleableElement`'s constructor applies the merged style, which
triggers `OnApplyTemplate` → `UpdateIsEnabled` →
`GestureRecognizers.Add(...)`. At that point `View`'s constructor body
has not yet subscribed to `_gestureRecognizers.CollectionChanged`, so
the tap gesture never reaches `CompositeGestureRecognizers`. The
iOS/MacCatalyst `GesturePlatformManager` attaches platform recognizers
exclusively from that composite collection, so no
`UITapGestureRecognizer` is ever created. Android and Windows resolve
taps from the raw `GestureRecognizers` collection, which is why only iOS
is affected. With a page-level style the template is applied after
construction (on parenting), so the composite collection stays in sync
and taps work.

**Fix**

After `View`'s constructor subscribes to the gesture collection, sync
any recognizers that were added during base construction into
`CompositeGestureRecognizers` (setting their `Parent`, as the
collection-changed path does). This repairs the general case — any
gesture wired while base constructors run — at no cost to views
constructed normally, whose collection is empty at that point.

**Tests**

| | Without fix | With fix |
| --- | --- | --- |
|
`TemplateFromAppLevelImplicitStyleAddsTapGestureToCompositeRecognizers`
| Fails — `CompositeGestureRecognizers` is empty, so the RadioButton
ignores taps on iOS | Passes — the tap gesture is present in both
collections |
| Full Controls.Core.UnitTests | — | No new failures |

### Issues Fixed

Fixes #14949

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
### Description of Change

When an absolute Shell route is prefixed with `..` segments — e.g.
`GoToAsync("//../../Page2")` while two registered-route pages are pushed
on the current tab — the `..` segments are silently lost.
`ShellUriHandler.FormatUri` only handles `..` on fully relative routes,
so for `//`-prefixed routes the dots reach `ConvertToStandardFormat`,
where standard `Uri` dot-segment normalization deletes them. The request
degrades to a plain `//Page2` tab switch and the pages stay on the
previous tab's navigation stack, so re-selecting that tab shows the old
detail page instead of its root.

Because the navigation target is a different `ShellSection`, the pop
cannot be expressed in the rewritten URI (stack diffing only applies to
the target section) — the pages have to be removed from the section
being navigated away from.

**Fix**

Capture the number of leading `..` segments before the request is
resolved (`ShellUriHandler.CountLeadingDotDotSegments`) and, once the
navigation is accepted and the shell element switch has completed,
remove one page per `..` from the top of the previous section's stack —
the same `RemovePage` pattern the modal cleanup in
`ShellNavigationManager.GoToAsync` already uses. The removal is clamped
at the section root, runs only when the section actually changed
(same-section absolute routes already reset their stack), and never runs
when navigation is cancelled or deferred.

**Tests**

Added to `ShellNavigatingTests` using the issue's exact scenario (tabs
Page1/Page2/Page3, registered routes Page4/Page5 pushed on Page3's tab).

| | Without fix | With fix |
| --- | --- | --- |
| `GoToAsync("//../../Page2")` | Switches to Page2; Page4 and Page5
remain on Page3's stack | Switches to Page2; Page3's stack back to its
root |
| `GoToAsync("//../Page2")` | Switches to Page2; both pages remain |
Switches to Page2; only Page5 popped |
| Existing Shell suites | — | 566/566 pass; full Core.UnitTests has no
new failures |

### Issues Fixed

Fixes #15166

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… bounds (#40100)

### Description of Change

On Android, a SwipeView stops tracking the swipe as soon as the pointer
leaves the bounds of its content while the gesture is still in progress,
and resumes only when the pointer re-enters — small vertical drift
during a horizontal swipe keeps "freezing" the gesture (very noticeable
with SwipeViews inside a CollectionView).

**Root cause**

Two guards re-evaluate an already-running gesture as if it were a new
one:

- `ProcessTouchMove` returns early when the current point is outside the
content bounds, even when `_isSwiping` is already set.
- `OnTouchEvent` filters `ACTION_MOVE` through `ShouldInterceptTouch`,
which recomputes the swipe direction from the total pointer travel —
once the vertical drift exceeds the horizontal distance it reclassifies
the gesture as Up/Down, finds no items for that direction and drops the
move.

**Fix**

Both checks now only apply before a swipe starts; once `_isSwiping` is
set, moves are processed wherever the pointer is, which is the standard
platform gesture behavior (the drawer, for example, keeps tracking past
its bounds).

A second commit applies non-animated swipe translations directly instead
of going through a zero-duration `ViewPropertyAnimator`. The
zero-duration animator still needs a frame to run, so a programmatic
`Open(animated: false)` followed by detaching the view left a pending
animator keeping the view tree alive — which made the existing
`ItemsDoNotLeak` device test order-sensitive. With the direct assignment
the SwipeView category is stable across repeated runs.

**Tests**

`SwipeViewTests.SwipeKeepsTrackingWhenThePointerLeavesTheBounds`
(Android device test): starts a swipe with synthetic motion events,
moves the pointer below the view bounds while continuing the horizontal
drag, and checks the content keeps following.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `The swipe stopped tracking when
the pointer left the bounds (TranslationX -52, was -52)` | Passes.
SwipeView category 22/22, three consecutive runs |

### Issues Fixed

Fixes #37089

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052)

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

### Description of Change

On Android with the handler-based Shell, an app crashes with
`InvalidOperationException: VirtualView cannot be null here` in
`ShellSectionWrapperFragment.OnResume()` when it resumes after a
ShellItem was replaced while it was in the background.

When a section is removed, `ShellSectionHandlerAdapter.Dispose()`
disconnects its handler. Since #37048 it leaves the wrapper fragment to
`FragmentManager`, which can still resume it. `OnResume()` already
returns early for a disconnected handler, but it checks
`_handler.VirtualView is null`. That reads the typed
`ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws
once disconnected, so the guard itself throws.

The fix checks the untyped `((IElementHandler)_handler).VirtualView`,
the same way `ShellSectionHandler.iOS.cs` does.

Not changed here: several other `VirtualView is null` checks in
`ShellSectionHandler.Android.cs` (for example in
`IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the
same problem. They aren't reached on this path, so I left them out to
keep this PR small.

### Tests

Added
`ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`.
It creates a section renderer, disposes it the same way
`ShellItemHandler.UpdateSections` does for a removed section, and
resumes its wrapper fragment.

Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36,
x86_64):
- With the fix: 80/80 pass.
- Without the fix: the new test fails with
`System.InvalidOperationException: VirtualView cannot be null here at
ShellSectionWrapperFragment.OnResume()`; the other 79 pass.

### Issues Fixed

Fixes #40051

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Generalize context transfer for all BindingBase types in BindableObject,
and ensure correct specificity/context handling in MultiBinding when
targeting BindingContext. Add tests to verify MultiBinding context
behavior in various scenarios.

Fixes #10792

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Add handling for Binding.DoNothing in value converters to skip
target/source updates in BindingExpression and TypedBinding. Introduce
BindingDoNothingTests to verify correct behavior for one-way, two-way,
initial binding, TargetNullValue, and StringFormat scenarios.

 Fixes #11740

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…9920)

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

### Issue details
On the Project page, iOS VoiceOver reads the names of Tags and Icons but
does not announce whether they are selected or unselected. The expected
behavior is for VoiceOver to announce each item’s name and selection
state.
 
### Root cause
For these selectable CollectionView items, Android and macOS announce
selection state through native accessibility behavior. iOS VoiceOver
does not announce the selected/unselected state, and the item
descriptions contain only the names. Therefore, the state must be
included in the semantic description on iOS; doing so on Android and
macOS would duplicate their native announcement.
 
### Description of changes
Updated the visual states in ProjectDetailPage.xaml to include
“Unselected” in the Normal state and append “Selected” to the item
description in the Selected state on iOS only.
 
### Issues Fixed

Fixes #39907

### Screenshot

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="2000" height="1000"
src="https://github.com/user-attachments/assets/9957c168-b220-43b6-9a1c-63514e73bddc">
| <img width="2000" height="1000"
src="https://github.com/user-attachments/assets/4c930934-937e-485d-aa91-9cae5630825d">
|

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
### Description of Change

When a modal page is pushed at startup, the Shell toolbar gets the
default dark color instead of the colors set on the Shell, and stays
wrong after the modal closes (on Android and Windows, which drive the
toolbar from the resolved `ShellAppearance`).

**Root cause**

`GetAppearanceForPivot` walks up from the pivot's presented page to
collect the `Shell.*` appearance values. For a `ShellSection` pivot,
`WalkToPage` used `IShellSectionController.PresentedPage`, which returns
the top modal page while a modal is open. Modal pages are parented to
the `Window`, not the Shell, so the walk immediately left the Shell
tree, found nothing and returned null — and the toolbar fell back to the
default colors.

**Fix**

`WalkToPage` now resolves the `ShellSection` to the top page of its own
navigation stack — exactly what `PresentedPage` returns when no modal is
open — so appearance resolution gives the same result whether or not a
modal is sitting on top.

**Tests**

`ShellAppearanceTests.AppearanceIsResolvedWhileAModalPageIsOpen`: sets
`Shell.BackgroundColor`, pushes a modal page, then registers an
appearance observer for the current section.

| | Without fix | With fix |
|---|---|---|
| `main` (2f3276c) | Fails: the observer gets a null appearance |
Passes; Controls.Core.UnitTests 6734 passed (the one failure is a
pre-existing decimal-separator locale test that fails on `main` on this
machine too) |

### Issues Fixed

Fixes #18409

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Refactor BindingCondition to track state via a new attached property,
ensuring triggers apply correctly when the bound value is initially
null. Update property change logic to only raise ConditionChanged on
actual state changes. Add unit tests to verify correct behavior with
null values and MultiTrigger scenarios, addressing issue #6847.

Fixes #6847

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…conversion during repeated rendering (#39909)

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


<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Root cause

The issue occurs because of missing deterministic disposal of temporary
Android graphics objects during repeated path rendering.
PlatformCanvas.ClipPath created Android Path objects without disposing
them, while arc-conversion helpers created undisposed RectF objects for
each arc segment. Their cleanup depended on garbage collection and
finalization, contributing to memory growth during sustained rendering.

### Solution description

The fix involves using scoped disposal for converted Android paths in
ClipPath, PlatformDrawPath, and FillPath, ensuring cleanup even when
subsequent operations throw. It also replaces temporary RectF
allocations with the coordinate-based ArcTo overload in all three
arc-conversion helpers.

This reduces platform-object allocations while preserving path geometry,
winding rules, and caller-owned PathF instances.

Validated the behavior in the following platforms
 
- [x] Android
- [ ] Windows
- [ ] iOS
- [ ] Mac
 
### Issues Fixed
  
Fixes #39675

### Output  ScreenShot

|Platform|Before|After|
|--|--|--|
|Android| <video
src="https://github.com/user-attachments/assets/252c5f3f-5393-414c-b0f7-b4572b1a9e14">|
<video
src="https://github.com/user-attachments/assets/122e7ef9-acb2-4b5d-9152-1bdeefa46ebf">|

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… view (#39900)

### Description of Change

With a `FlyoutPage` on Android, a tap on an empty area of the open
flyout fell through to the detail page behind it and clicked its
controls. The flyout view is added to the `DrawerLayout` without
anything consuming the touches its content doesn't handle, so an
unhandled `ACTION_DOWN` inside the open drawer continued to the detail
sibling — the classic Android drawer issue that a plain app solves with
`android:clickable="true"` on the drawer pane.

**Fix**

`MauiDrawerLayout.SetFlyoutView` now subscribes a `Touch` handler on the
flyout view that marks the leftover events handled. `MauiDrawerLayout`
is shared, so this covers both `FlyoutPage` and the Shell flyout.

- Controls inside the flyout are unaffected: the handler only sees
touches no child consumed.
- The drawer's swipe-to-close gesture is unaffected: `DrawerLayout`
intercepts drags before they reach the pane.
- The accessibility tree is unchanged, because an `OnTouchListener`
doesn't mark the view clickable the way `Clickable = true` would.
- There's deliberately no unsubscribe in `Disconnect`: the handler is a
static method that keeps nothing alive, and the Java peer can already be
disposed by the time the Shell handler disconnects, so touching it there
would throw an `ObjectDisposedException`. The subscription on a replaced
flyout view is removed in `SetFlyoutView` itself.

**Tests**

`FlyoutPageTests.TapOnTheOpenFlyoutDoesNotReachTheDetailPage` (Android
device test): opens the flyout, dispatches a tap in the middle of it and
checks the detail's platform view never sees the touch.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: the tap reached the detail page |
Passes. FlyoutPage category 18/18, Shell category 184/184 |

### Issues Fixed

Fixes #14609
…ed scrolling (#39882)

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

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

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

Fix CollectionView height updates after replacing ItemsSource with fewer
items on iOS and Mac Catalyst, while preserving sizing behavior when
CollectionView is nested inside ScrollView.

In #38276, CollectionView retains its previously rendered
height after the item count decreases, leaving unused space and stale
Height/SizeChanged values. The previous fix, #38441, moved
content-size checking exclusively to ViewDidLayoutSubviews. This
introduced the nested-scroll regression reported in #39847:
the CollectionView could remain smaller than its content, creating an
additional vertical scroll range inside the outer ScrollView. That fix
was reverted by #39856.

This replacement builds on the reverted implementation:

- Preserve the existing ViewWillLayoutSubviews content-size check.
- Add a guarded ViewDidLayoutSubviews check to detect self-sizing
content changes resolved during native layout, allowing the
CollectionView to shrink.
- Skip the post-layout check when content exceeds the current bounds in
the scrolling direction, without updating the cached content size. This
leaves growth detection to the pre-layout check and avoids the
nested-scroll regression.
- Refresh empty-source tracking when replacing ItemsSource so grouped
collections collapsed to zero can grow again, even when UIKit defers
data-source callbacks.
- Restore the required iOS and Mac Catalyst public API entries for the
layout callback override.


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

Related: #39847 — adds coverage to prevent reintroducing the
nested-scroll regression already addressed by the revert.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
<!-- 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!


### Root cause: 

- `StrokeLineJoin` was correctly mapped to Core Graphics, but the border
stroke was clipped to the original shape path. Round and Bevel join
geometry extends beyond convex path corners, so the active clip removed
the visible join geometry and caused corners to appear sharp.

### Description of Change

- The iOS `MauiCALayer` renderer now uses `RequiresUnclippedStroke` to
identify Round, Bevel, and custom-MiterLimit configurations. For these
cases, it renders the stroke on an inset path without the outer shape
clip, preserving the complete join geometry inside the `CALayer` bounds.
- The background is clipped to the inset path so it does not appear in
bevelled corner cutouts.
- Default Miter rendering with the default miter limit retains the
existing clipped rendering path, preserving current border dimensions
and dash placement for unaffected Border scenarios.

### Issues Fixed

Fixes #29743

### Tested the behavior in the following platforms

- [ ] Windows
- [ ] Android
- [x] iOS
- [x] Mac

| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="1125" height="2436" alt="BeforeFix29743"
src="https://github.com/user-attachments/assets/45ada062-5d57-491c-a863-2cbbb7b7d9f4"
/> | <img width="1125" height="2436" alt="AfterFix29743"
src="https://github.com/user-attachments/assets/98ed0c28-7a5d-480e-9066-b88330bb5032"
/> |
<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


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

<!--
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: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ng (#39911)

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

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Custom font loading can pump STA messages. Performing that work
synchronously during a XAML layout tick can cause dispatcher reentrancy
and a native WinUI fail-fast crash.

Defer font-image rendering with Task.Yield() before entering the
existing Win2D rendering pipeline. This preserves UI-thread rendering
while allowing the current layout tick to finish. Also honor
cancellation before rendering and after the yield, avoid logging
expected cancellation as a warning, and dispose CanvasTextFormat.

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

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->
…40157)

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

### Description of Change

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

Adds executable XAML regression coverage for `{Binding A.B.C.Text}` when
intermediate references are null despite non-nullable declarations. Each
test runs with Runtime, XamlC, and SourceGen inflation.

**Investigation:** The `11.0.0` release tag still bases null-conditional
access on nullable annotations and generates `source.A.B.C.Text`.
Current `net11` already includes the fix from #36444
(`803bc81a488007ce0647ab5693cf4811b8ce4844`), which uses runtime
nullability and generates `source.A?.B?.C?.Text`. No additional
production-code change is needed on this base; this PR adds behavioral
coverage rather than duplicating that fix.

**Important testing detail:** `TypedBinding` catches getter
`NullReferenceException`s. Checking only the resulting label text or
using `Assert.Throws` misses the issue. The new test captures
thread-local first-chance exceptions during binding evaluation, with the
AppDomain event handler removed in `finally`. This detects
debugger-visible exceptions even when the binding engine catches them.
It does not claim that every exception escapes the binding engine or
crashes the app.

The other tests verify recovery when A, B, or C becomes null and is
restored, leaf-property updates, detached-leaf changes not affecting the
target value, and two-way bindings writing null to a
non-nullable-declared reference property.

**Proposed resolution:** Retain the runtime-nullability fix already
present in `net11` and ensure it is included in the applicable servicing
release. This test-only PR protects that behavior. Existing #36444
coverage inspects generated source; these tests execute the inflated
bindings.

cc @simonrozsival - the fix from #36444 is present on `net11` but absent
from the `11.0.0` tag. The new executable test reproduces the
SourceGen-only first-chance exceptions with the shipped generator and
passes with the existing fix.

#### Validation

The A/B check replaced only `CompiledBindingMarkup.cs` with its contents
at `4b41c78edb15307a84caf5b4bfe89a6df0813dcb`, which are byte-identical
to that file in the `11.0.0` tag. All other code remained at current
`net11`; this is not a full released-package/device run.

| Generator implementation | Runtime | XamlC | SourceGen |
| --- | --- | --- | --- |
| Shipped `11.0.0` generator file | 3 passed | 3 passed | 2 passed,
first-chance exception test failed |
| Current `net11` / existing #36444 fix | 3 passed | 3 passed | 3 passed
|

Exact commands and results:

```powershell
$PSDefaultParameterValues["EstablishBrokenBaseline.ps1:BaseBranch"] = "4b41c78edb15307a84caf5b4bfe89a6df0813dcb"
& .github/skills/verify-tests-fail-without-fix/scripts/verify-tests-fail.ps1 -PRNumber 40139 -TestType XamlUnitTest -TestFilter "FullyQualifiedName~Maui40139" -FixFiles src/Controls/src/SourceGen/CompiledBindingMarkup.cs -BaseBranch 4b41c78 -RequireFullVerification
```

Result: **VERIFICATION PASSED** - 1 failed / 8 passed with the shipped
generator file; 9 passed with the current generator. `40139` is the
report-directory identifier for the issue investigation. The PowerShell
default also pins the shared baseline helper, which otherwise loses the
explicit base during dot-sourcing.

```shell
dotnet build Microsoft.Maui.BuildTasks.slnf -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false -v q
```

Result: passed.

```shell
dotnet test src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj -c Debug -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -p:IncludeMacOSTargetFrameworks=false --filter 'FullyQualifiedName~Maui40139' -v q
```

Result: passed, 9 tests. Executed locally on macOS using the installed
.NET 11 RC2 SDK; no native Android/iOS device validation was performed.

### 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 #40139; adds regression coverage for the existing fix to
#36313. This PR does not introduce a new production fix or establish
that a serviced package has shipped.

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

---------
…40150)

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

### Description of Change

On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a
URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl,
true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as
`https://example.com/` is treated as a relative file path and becomes a
`file:` URL under the current directory. The loaded document therefore
never gets the origin the app asked for, so these break:

- relative URLs that should resolve against a remote base
- cookies and storage scoped to that origin
- services that identify the embedding app by its `Referer`. For
example, YouTube's embedded player requires one ([Required Minimum
Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)).
Google's documented way to provide it on iOS is
`loadHTMLString:baseURL:` with an https base URL, which is what
`HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows
"Error 153".

Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so
this makes iOS and Mac Catalyst behave like Android.

**Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`:

| `BaseUrl` | Before | After |
| --- | --- | --- |
| `https://example.com/` | `file:///…/https:/example.com/` (a file URL
under the current directory) | `https://example.com/` |
| a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory
file URL | unchanged |
| `null` / empty | app bundle path | unchanged |

A value counts as a URL when `NSUrl.FromString` parses it with a scheme.
Anything else keeps the existing file-path behaviour, so apps that pass
a bundle path for local content are not affected.

No open PR addresses this issue.

### Tests

Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac
Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI`
from the page:

- `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for
`https://example.com/` and `https://example.com/content/`
- `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing
file-path behaviour
- `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests

Run locally with xharness, `Category=WebView`, on this branch's base
`net11` (e7f7353):

| Run | Result |
| --- | --- |
| iOS simulator 26.5, without the fix | both scheme cases fail:
`Expected "https://example.com/"`, `Actual
"file:///Users/…/Library/Develop…"`. The file-path case passes. |
| iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped |
| Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped |

### Issues Fixed

Fixes #19792

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ation (#40148)

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


### Issue

After upgrading from .NET MAUI 10 to 11, XAML source generation fails
when a `DynamicResource` key is supplied through a nested markup
extension:

```xml
<Label FontSize="{DynamicResource {x:Static local:FontSizes.Medium}}" />
```

Here, `FontSizes.Medium` is a public string constant containing a
resource dictionary key. Instead of resolving that key, compilation
reports:

```text
MAUIG1001: Unable to cast object of type
'Microsoft.Maui.Controls.Xaml.ElementNode' to type
'Microsoft.Maui.Controls.Xaml.ValueNode'.
```

The exact error was reproduced in the MacCatalyst Sandbox build before
applying this fix.

### Root cause

`KnownMarkups.ProvideValueForDynamicResourceExtension` optimizes
resource creation during the source generator's early value-creation
pass. It assumes the key node is a `ValueNode` containing a literal
string and casts it directly.

Nested markup extensions such as `x:Static` are represented by
`ElementNode` instances, so this assumption causes an invalid cast
before the nested extension can be evaluated.

### Fix

Restrict the early optimization to literal string keys. When the key is
not a literal string, decline the optimization and let the existing
markup-extension pipeline evaluate the nested value, assign
`DynamicResourceExtension.Key`, and invoke `ProvideValue` normally.

This preserves the existing literal-key fast path without adding
special-case handling for `x:Static` or changing the public API.

### Regression coverage

Add 10 parameterized cases covering literal keys and nested `x:Static`
keys backed by constants, static readonly fields, and static properties,
plus nested `x:String` values. Both positional and explicit `Key=` forms
are covered.

Each case compiles and executes the generated page, verifies the initial
font size, and confirms that replacing the resource updates the label's
font size. Before the fix, nine cases failed and the positional
literal-key control passed; afterward, all 10 pass.


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

<!--
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 <42434498+kubaflo@users.noreply.github.com>
### Description of Change

With the .NET 11 implicit XAML namespaces feature, `{x:Static
Routes.LineItemsPage}` fails with `MAUIG1001: Type not found Routes`
when `Routes` is produced by another source generator (e.g.
epj.RouteGenerator in the repro project), while the same reference works
with an explicit `xmlns` prefix. Roslyn source generators cannot see
each other's output, so the XAML source generator has no symbol for such
types. For explicit `clr-namespace:` prefixes it already defers to the
C# compiler by emitting `global::{ns}.{Type}.{member}` as a guess (which
is why the prefix workaround works), but for the implicit/global xmlns —
where a set of candidate namespaces is registered rather than a single
one — no such fallback existed, and the generator reported a hard error.
Types that are part of the compilation already resolve correctly through
the implicit xmlns in all inflators, and XamlC/runtime inflation are
unaffected since they run against the compiled assembly.

**Fix**

When `x:Static` can't resolve its type symbol and the xmlns is an
aggregated one (such as the implicit
`http://schemas.microsoft.com/dotnet/maui/global`), resolution is
deferred to the C# compiler, exactly like the existing `clr-namespace:`
fallback. The deferral candidates are deliberately narrow: only CLR
namespaces (aggregated xmlns can also map to other xmlns URIs, which are
filtered out) that the **current assembly** registered on that xmlns —
metadata references are immutable, so a type the generator cannot see
can only materialize in the compilation's own assembly, as another
generator's output. In practice that leaves:

- one candidate (the common case): the member access is emitted fully
qualified, `global::Test.Routing.Routes.LineItemsPage` — no usings, no
name-collision surface;
- several candidates (the app registered 2+ of its own namespaces on one
xmlns): the member access is emitted unqualified and the candidates
become `using` directives in the generated file, so the compiler
resolves the name or reports CS0104 on a genuine ambiguity;
- no valid candidate: the existing `MAUIG1001` error is reported, as
before.

The usings travel as marker lines inside the generated body and are
lifted into `using` directives by the final code writers, so they reach
both `InitializeComponent` and the Hot Reload `UpdateComponent` output
(which previously discarded them and produced an uncompilable update for
this scenario).

**Tests**

`Issues/Maui39763.cs` reproduces the scenario with the source generator
driver: the x:Static type is absent from the compilation the generator
sees (like another generator's output) but registered in the global
xmlns, and the tests verify the generated code compiles once the type
exists in the final compilation.

| | Without fix | With fix |
| --- | --- | --- |
| `XStaticWithGeneratedTypeInImplicitXmlns` | Fails: `error MAUIG1001: …
Type not found Routes.` | Passes; asserts the exact
`global::Test.Routing.Routes.LineItemsPage` output |
| `XStaticWithGeneratedTypeInAggregatedXmlns` (urn: aggregation) |
Fails: emitted `using urn:test39763;` | Passes |
| `XStaticWithGeneratedTypeInImplicitXmlnsMultipleNamespaces` | — |
Passes; pins the multi-candidate usings path |
| `XStaticWithResolvableTypeInImplicitXmlns` (control) | Passes | Passes
|
| `Maui39763Tests.XStaticFallbackUsings_ReachUpdateComponent` (Hot
Reload) | Fails: no `using` in `UpdateComponentSource` | Passes; all
generated sources compile |
| Full Xaml.UnitTests | 2 pre-existing locale failures | Same 2, zero
new (2183 passed) |
| Full SourceGen.UnitTests | — | 629 passed / 0 failed |

Known residual, intrinsic to CSC deferral: in the multi-candidate case a
field (`x:Name`) or a type in the page's namespace with the same name as
the deferred type can still shadow it — the single-candidate path, which
covers the issue's scenario, is immune.

### Issues Fixed

Fixes #39763

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…request (#40124)

### Description of Change

On Android, pressing the system back button while an animated
`NavigationPage.PushAsync` is still running pops the page natively
without MAUI being notified: during an in-flight fragment transaction
the back press is consumed by an AndroidX callback registered later than
MAUI's (`OnBackPressedDispatcher` invokes the most recently added
enabled callback). After that:

- the `Task` returned by `PushAsync` never completes —
`StackNavigationManager` finishes a navigation when the outgoing
fragment's view is destroyed, and a cancelled transition never destroys
it,
- `NavigationStack`/`CurrentPage` still contain the pushed page while
the screen shows the previous one, and the next back press is delivered
to the invisible page,
- anything awaiting that `PushAsync` hangs, so the app looks frozen.

**Fix**

`StackNavigationManager` now reconciles when the platform back stack
pops without a MAUI request. On every `OnDestinationChanged` that was
not produced by `ApplyNavigationRequest` itself (guarded by a flag
around the request processing), it compares the platform back-stack
depth with the cross-platform stack; when the platform has fewer
entries, it trims the stack to what is actually on screen and completes
the pending navigation through the existing `NavigationFinished` path —
the same reconciliation `IStackNavigation.NavigationFinished` already
performs on the Controls side (stack sync, `CurrentPage`, toolbar, task
completion).

This is the outcome the issue asks for: the interrupted push is treated
as cancelled, the `PushAsync` task completes, and the cross-platform
stack matches what is displayed.

**Tests**


`NavigationPageTests.PushCompletesWhenThePlatformPopsDuringTheTransition`
(Android device test): starts an animated push and immediately pops the
platform back stack — what the stolen back press does — then checks the
push task completes, the stack has a single page and `CurrentPage` is
the root again.

| | Without fix | With fix |
|---|---|---|
| Android emulator (API 37) | Fails: `PushAsync never completed after
the platform popped the page` | Passes. NavigationPage category 25
passed / 1 failed / 1 skipped — the one failure (`BarBackgroundColor
respects Android system chrome opt-out`) fails identically on unmodified
`main` on the same emulator |

### Issues Fixed

Fixes #39456

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Handle cancellation during image loading by treating it as a failure.

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

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

<img width="1292" height="995" alt="image"
src="https://github.com/user-attachments/assets/ed1b0a9e-a1cd-4de0-88ce-6b61da262efa"
/>

---------

Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 13:54 — with GitHub Actions Inactive
@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 -- 40577

Or

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

@kubaflo kubaflo mentioned this pull request Nov 24, 2026
1 task done
@azure-pipelines

This comment has been minimized.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 24, 2026 13:54 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Skill Validation Results

@kubaflo — new skill validation results are available based on this last commit: 3fe3f71.
To request a fresh validation after new comments or commits, comment /evaluate-skills.

Overall Passed Static Passed LLM Skipped Skills 27 Agents 7

✅ Skill Validation Results — 3fe3f71 · [Forward fixes] net11 to main · 2026-11-24T14:01:52Z

✅ Static Checks Passed

Skills: 27 | Eval specs linted: 17

Full lint output
── .github/skills/agentic-labeler/tests/eval.vally.yaml
npm warn deprecated @github/copilot-sdk@1.0.34: Deprecated: migrate to @microsoft/copilot-sdk. Migration docs: https://github.com/microsoft/copilot-sdk/blob/main/docs/v2-breaking-changes.md
npm warn deprecated @github/copilot-sdk-linux-x64@1.0.34: Legacy platform dependency. Migrate the parent SDK to @microsoft/copilot-sdk. Migration docs: https://github.com/microsoft/copilot-sdk/blob/main/docs/v2-breaking-changes.md
Vally collects pseudonymous usage telemetry (command name, version, outcome, duration, persistent device identifier (when available), and coarse OS/runtime info) to improve the product. No prompts, datasets, file paths, or arguments are collected.
Opt out any time by setting VALLY_TELEMETRY_OPTOUT=1 or DO_NOT_TRACK=1.
Learn more: https://aka.ms/vally/telemetry
✔ .github/skills/agentic-labeler/tests/eval.vally.yaml is valid
── .github/skills/analyze-sessions/tests/eval.vally.yaml
✔ .github/skills/analyze-sessions/tests/eval.vally.yaml is valid
── .github/skills/ci-fix/tests/eval.ownership.vally.yaml
✔ .github/skills/ci-fix/tests/eval.ownership.vally.yaml is valid
── .github/skills/ci-fix/tests/eval.vally.yaml
✔ .github/skills/ci-fix/tests/eval.vally.yaml is valid
── .github/skills/code-review/tests/eval.inline-findings.vally.yaml
✔ .github/skills/code-review/tests/eval.inline-findings.vally.yaml is valid
── .github/skills/code-review/tests/eval.producer-trace.vally.yaml
✔ .github/skills/code-review/tests/eval.producer-trace.vally.yaml is valid
── .github/skills/code-review/tests/eval.trim-aot.vally.yaml
✔ .github/skills/code-review/tests/eval.trim-aot.vally.yaml is valid
── .github/skills/code-review/tests/eval.vally.yaml
✔ .github/skills/code-review/tests/eval.vally.yaml is valid
── .github/skills/code-review/tests/hermeticity.vally.yaml
✔ .github/skills/code-review/tests/hermeticity.vally.yaml is valid
── .github/skills/code-review/tests/soak.capability.vally.yaml
✔ .github/skills/code-review/tests/soak.capability.vally.yaml is valid
── .github/skills/evaluate-pr-tests/tests/eval.vally.yaml
✔ .github/skills/evaluate-pr-tests/tests/eval.vally.yaml is valid
── .github/skills/pr-review/tests/eval.gh-auth.vally.yaml
✔ .github/skills/pr-review/tests/eval.gh-auth.vally.yaml is valid
── .github/skills/review-test-failures/tests/eval.vally.yaml
✔ .github/skills/review-test-failures/tests/eval.vally.yaml is valid
── .github/skills/try-fix/tests/eval.restore.vally.yaml
✔ .github/skills/try-fix/tests/eval.restore.vally.yaml is valid
── .github/skills/try-fix/tests/eval.vally.yaml
✔ .github/skills/try-fix/tests/eval.vally.yaml is valid
── .github/skills/verify-tests-fail-without-fix/tests/eval.protocol.vally.yaml
✔ .github/skills/verify-tests-fail-without-fix/tests/eval.protocol.vally.yaml is valid
── .github/skills/verify-tests-fail-without-fix/tests/eval.vally.yaml
✔ .github/skills/verify-tests-fail-without-fix/tests/eval.vally.yaml is valid

⏭️ LLM Evaluation: Skipped

No changed skills with eval specs found.

🔍 Full results and investigation steps

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

### Description of Change

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

Backport #40481 from `release/11.0.1xx-sr2` to `net11`. The change
prevents re-entrant CollectionView remaining-items threshold
notifications and skips threshold evaluation when the scrolled event
replaces the items source. It includes the original iOS/MacCatalyst
device tests.

Source commit: `4858add2c0fdb0fc6ccfff39ee2dfde40b61e78d`.

**Validation**

- `git diff --cached --check` - passed.
- `git diff --cached | git patch-id --stable` - matched the patch ID of
source commit `4858add2c0fdb0fc6ccfff39ee2dfde40b61e78d`.
- Building `Microsoft.Maui.BuildTasks.slnf` failed locally with
`NETSDK1140`: the installed Apple workload accepts platform version 27.2
while the projects request 27.0.
- iOS and MacCatalyst device tests were not run locally; CI validation
is required.

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

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->
@kubaflo
kubaflo marked this pull request as ready for review November 24, 2026 14:14
Copilot AI balanced review requested due to automatic review settings November 24, 2026 14:14
@kubaflo

kubaflo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto stamp

Copilot AI 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.

🟡 Changes recommended

Changing IconImageSource after menu creation leaves the displayed icon unchanged because the item handler is disconnected; source resolution must use the parent window’s MauiContext instead.

1 open issue
What changed in this PR

This PR forwards net11 servicing changes into main, replacing #40576 with an integration that tracks the live servicing branch. The supplied changes span platform controls, XAML processing, regression tests, and build infrastructure.

Changes:

  • Forward fixes for control rendering, input, navigation, menus, bindings, and lifecycle handling.
  • Extend XAML resource and extension-property support, public API records, and regression coverage.
  • Update SDK pins, isolate build-task restore outputs, and improve CI provisioning and test reliability.
File Description
src/​SingleProject/​Resizetizer/​test/​UnitTests/​FilenameTests.cs Adds Windows-only fact attribute.
src/​SingleProject/​Resizetizer/​src/​SkiaSharpTools.cs Exposes file-error constants internally.
src/​SingleProject/​Resizetizer/​src/​GenerateSplashStoryboard.cs Retries themed-asset cleanup.
src/​SingleProject/​Resizetizer/​src/​GenerateSplashAssetCatalog.cs Retries stale splash-file cleanup.
src/​SingleProject/​Resizetizer/​src/​GenerateSplashAndroidResources.cs Retries night-resource cleanup.
src/​Graphics/​src/​Graphics/​Platforms/​Windows/​GraphicsExtensions.cs Corrects geometry figure tracking.
src/​Graphics/​src/​Graphics/​Platforms/​Android/​TextLayoutUtils.cs Disposes native layout builder.
src/​DotNet/​DotNet.csproj Removes conflicting bundled manifests.
src/​Core/​tests/​DeviceTests/​Stubs/​HtmlWebViewSourceStub.cs Supports HTML base URLs.
src/​Core/​tests/​DeviceTests/​Stubs/​CountedImageSourceServiceStub.Android.cs Models failures after cancellation.
src/​Core/​tests/​DeviceTests/​Stubs/​ControlledImageSourceService.Windows.cs Adds controllable image-service results.
src/​Core/​src/​PublicAPI/​net-maccatalyst/​PublicAPI.Unshipped.txt Records menu source mapper.
src/​Core/​src/​PublicAPI/​net-ios/​PublicAPI.Unshipped.txt Records menu source mapper.
src/​Core/​src/​Platform/​Windows/​WebViewExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​TimePickerExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​TextBoxExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​StepperExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​ShapesExtensions.cs Refreshes shadows after shape changes.
src/​Core/​src/​Platform/​Windows/​SearchBarExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​RadioButtonExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​PickerExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​MauiPageControl.cs Uses mapped indicator position.
src/​Core/​src/​Platform/​Windows/​DatePickerExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​ContentPanel.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​Windows/​ButtonExtensions.cs Invalidates pending background-image requests.
src/​Core/​src/​Platform/​iOS/​UIPageControlExtensions.cs Accounts for templated indicators when hiding.
src/​Core/​src/​Platform/​iOS/​SwipeViewExtensions.cs Bounds and filters swipe-item measurement.
src/​Core/​src/​Platform/​iOS/​MenuExtensions.cs Adds menu-image update helper.
src/​Core/​src/​Platform/​iOS/​MauiUIApplicationDelegate.Menu.cs Adds command-image synchronization.
src/​Core/​src/​Platform/​iOS/​MauiSwipeView.cs Validates swipe starts and preserves active gestures.
src/​Core/​src/​Platform/​iOS/​KeyboardAutoManagerScroll.cs Releases scrolling when parents handle keyboard insets.
src/​Core/​src/​Platform/​Android/​WrapperView.cs Avoids per-invalidation runnable allocations.
src/​Core/​src/​Platform/​Android/​MauiPageControl.cs Adds braces around shape reset.
src/​Core/​src/​Platform/​Android/​MauiDrawerLayout.cs Consumes otherwise-unhandled flyout touches.
src/​Core/​src/​Platform/​Android/​ImageSourcePartExtensions.cs Treats canceled-load failures as cancellation.
src/​Core/​src/​Hosting/​LifecycleEvents/​AppHostBuilderExtensions.iOS.cs Avoids destroying disconnected windows again.
src/​Core/​src/​Handlers/​View/​ViewHandler.Windows.cs Resets reused wrappers and background requests.
src/​Core/​src/​Handlers/​Slider/​SliderHandler.Windows.cs Invalidates thumb-image loading on disconnect.
src/​Core/​src/​Handlers/​SearchBar/​SearchBarHandler2.Android.cs Synchronizes read-only text and keyboard behavior.
src/​Core/​src/​Handlers/​ScrollView/​ScrollViewHandler.Android.cs Detaches content before reparenting.
src/​Core/​src/​Handlers/​MenuFlyoutItem/​MenuFlyoutItemHandler.iOS.cs Adds image-source mapping.
src/​Core/​src/​Handlers/​MenuFlyoutItem/​MenuFlyoutItemHandler.cs Enables Apple menu-source mapping.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.Standard.cs Adds standard template-mapping stub.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.cs Registers indicator-template mapping.
src/​Core/​src/​Handlers/​IndicatorView/​IndicatorViewHandler.Android.cs Rebuilds dynamically changed indicator templates.
src/​Core/​src/​Handlers/​Image/​ImageHandler.iOS.cs Ignores window changes after disconnect.
src/​Core/​src/​Handlers/​Entry/​EntryHandler2.Android.cs Updates read-only clear-button and keyboard behavior.
src/​Core/​src/​Handlers/​Entry/​EntryHandler.Android.cs Updates read-only clear-button and keyboard behavior.
src/​Core/​src/​Handlers/​Editor/​EditorHandler2.Android.cs Synchronizes read-only text and keyboard behavior.
src/​Core/​src/​Handlers/​Editor/​EditorHandler.Android.cs Synchronizes read-only text and keyboard behavior.
src/​Core/​src/​Fonts/​FontUriHelper.Windows.cs Resolves packaged font URIs.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionPropertiesReadOnlyMember.rt.xaml Adds read-only member precedence fixture.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionPropertiesQualified.rt.xaml Adds qualified missing-property fixture.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionPropertiesOutOfScope.rt.xaml Adds namespace-scope rejection fixture.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionPropertiesNestedAmbiguity.rt.xaml Adds nested ambiguity fixture.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionPropertiesLookalike.rt.xaml Adds false extension-container fixture.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionPropertiesLeaked.rt.xaml Adds assembly-scope isolation fixture.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionPropertiesErrors.rt.xaml Adds ambiguous extension-property fixture.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionContainers.OutOfScope.cs Defines unmapped extension properties.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionContainers.More.cs Defines globally mapped extension properties.
src/​Controls/​tests/​Xaml.UnitTests/​ScopedExtensionContainers.Http.cs Defines an HTTP-prefixed CLR namespace fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui40328.sgen.xaml Adds inline-code event fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui40139.xaml Adds nested binding-path fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui39132.xaml.cs Checks data-type markup is not instantiated.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui39132.xaml Supplies data-type markup regression fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29708External.rt.xaml Adds external global-namespace fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29708.xaml Adds global type and markup-resolution fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589StylesLocal.xaml Defines local resource precedence fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Styles.xaml Defines cross-dictionary resource consumers.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Reversed.xaml Exercises reversed dictionary order.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Overrides.xaml Supplies overriding resource value.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Override.xaml Exercises merged-resource override precedence.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Nested.xaml Exercises nested merged dictionaries.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Mixed.xaml Mixes source-based and typed dictionaries.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Local.xaml Exercises dictionary-local resource precedence.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589LibraryXc.xc.xaml Adds XamlC dictionary fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589LibrarySg.sgen.xaml Adds source-generated dictionary fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Library.xaml Defines nested dictionary library.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Content.xaml Exercises added content in typed dictionaries.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589Colors.xaml Supplies shared resource colors.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589App.xaml Exercises application-level merged dictionaries.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui29589.xaml Adds merged-dictionary regression fixture.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui24667Rd2.rt.xaml Defines cross-dictionary style inheritance.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui24667Rd1.rt.xaml Supplies base style resource.
src/​Controls/​tests/​Xaml.UnitTests/​Issues/​Maui24667.xaml Exercises merged and keyed style inheritance.
src/​Controls/​tests/​Xaml.UnitTests/​GlobalScopedExtensionProperties.rt.xaml Exercises globally scoped extension properties.
src/​Controls/​tests/​Xaml.UnitTests.ExternalAssembly/​UsingExtensionContainers.cs Supplies external namespace-only extensions.
src/​Controls/​tests/​Xaml.UnitTests.ExternalAssembly/​ScopedExtensionContainers.cs Supplies explicitly mapped external extensions.
src/​Controls/​tests/​Xaml.UnitTests.ExternalAssembly/​LeakedExtensionContainers.cs Supplies assembly-isolation negative fixture.
src/​Controls/​tests/​Xaml.UnitTests.ExternalAssembly/​ExtensionPropertyContainers.cs Supplies real and lookalike extension containers.
src/​Controls/​tests/​TestCases.Shared.Tests/​UITest.cs Restores fixture state after session recovery.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​XFIssue/​Issue2266.cs Re-enables Android flyout navigation coverage.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​LongPressGestureInteraction.cs Checks Apple long-press event timing.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue40279.cs Tests Shell replacement while stopped.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue39630.cs Tests selection without ancestor tap propagation.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue39055.cs Tests tab automation identifiers.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue35516.cs Tests dynamic search text transformation.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue35516_1.cs Tests initial search character spacing.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue34848.cs Selects an available Windows calendar date.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue31899.cs Normalizes header/footer test starting state.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue31128.cs Tests dynamic indicator templates.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue29153.cs Tests grouped last-item scrolling.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue26049.cs Uses updated tab automation identifier.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue24571.cs Tests looping carousel threshold events.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue23902.cs Waits for navigation completion.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue18371.cs Tests toolbar color after modal dismissal.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue17664.cs Re-enables Mac Catalyst coverage.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue14708.cs Checks keyboard visibility in landscape.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​FeatureMatrix/​HybridWebViewFeatureTests.cs Checks document position after reset.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​FeatureMatrix/​BorderFeatureTests.cs Re-enables Apple border-shape tests.
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​CollectionView/​CollectionViewUITests.HeaderAndFooter.cs Checks horizontal-grid header bounds.
src/​Controls/​tests/​TestCases.HostApp/​Platforms/​MacCatalyst/​SceneDelegate.cs Removes custom scene delegate.
src/​Controls/​tests/​TestCases.HostApp/​Platforms/​MacCatalyst/​Info.plist Removes explicit scene configuration.
src/​Controls/​tests/​TestCases.HostApp/​Platforms/​iOS/​SceneDelegate.cs Removes custom scene delegate.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​XFIssue/​Issue2266.cs Applies flyout container safe-area handling.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​XFIssue/​Github5623.xaml Explicitly preserves collection scroll offset.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​Issue26810Vertical.cs Adds vertical collection regression page.
src/​Controls/​tests/​SourceGen.UnitTests/​HotReload/​AiAssisted/​README.md Documents nested-content test coverage.
src/​Controls/​tests/​SourceGen.UnitTests/​HotReload/​AiAssisted/​NestedControlHotReloadTests.cs Removes obsolete assertion helper.
src/​Controls/​tests/​DeviceTests/​TestCategory.cs Adds Switch test category.
src/​Controls/​tests/​DeviceTests/​Resources/​Raw/​HybridTestRoot/​urlresolution.html Reports response content type.
src/​Controls/​tests/​DeviceTests/​Elements/​CarouselView/​CarouselViewTests.Windows.cs Waits for deferred scroll request.
src/​Controls/​tests/​DeviceTests/​Elements/​Border/​BorderTests.Windows.cs Checks native clipping structure directly.
src/​Controls/​tests/​DeviceTests/​Controls.DeviceTests.csproj Includes Windows font test asset.
src/​Controls/​tests/​Core.UnitTests/​SwitchUnitTests.cs Checks single color-mapping notifications.
src/​Controls/​src/​Xaml/​XamlNode.cs Preserves local default namespaces.
src/​Controls/​src/​Xaml/​PublicAPI/​netstandard/​PublicAPI.Unshipped.txt Records style hot-reload APIs.
src/​Controls/​src/​Xaml/​PublicAPI/​net/​PublicAPI.Unshipped.txt Records style hot-reload APIs.
src/​Controls/​src/​Xaml/​PublicAPI/​net-windows/​PublicAPI.Unshipped.txt Records style hot-reload APIs.
src/​Controls/​src/​Xaml/​PublicAPI/​net-maccatalyst/​PublicAPI.Unshipped.txt Records style hot-reload APIs.
src/​Controls/​src/​Xaml/​PublicAPI/​net-ios/​PublicAPI.Unshipped.txt Records style hot-reload APIs.
src/​Controls/​src/​Xaml/​PublicAPI/​net-android/​PublicAPI.Unshipped.txt Records style hot-reload APIs.
src/​Controls/​src/​Xaml/​PruneIgnoredNodesVisitor.cs Adds removal of inline-code directives.
src/​Controls/​src/​Xaml/​FillResourceDictionariesVisitor.cs Handles deferred dictionaries during error recovery.
src/​Controls/​src/​SourceGen/​xlf/​MauiGResources.Designer.cs Exposes namespace and extension diagnostics.
src/​Controls/​src/​SourceGen/​XamlNodeDiff.cs Makes node-value comparison reusable internally.
src/​Controls/​src/​SourceGen/​XamlDiagnosticHelpers.cs Adds diagnostic suppression parsing.
src/​Controls/​src/​SourceGen/​Visitors/​SetPropertiesVisitor.cs Creates deferred dictionaries during merging.
src/​Controls/​src/​SourceGen/​Visitors/​CreateValuesVisitor.cs Defers merged-dictionary construction.
src/​Controls/​src/​SourceGen/​ITypeSymbolExtensions.Maui.cs Allows nullable heuristic context.
src/​Controls/​src/​SourceGen/​Controls.SourceGen.csproj Includes shared XML type helpers.
src/​Controls/​src/​SourceGen/​AnalyzerReleases.Unshipped.md Registers new XAML diagnostics.
src/​Controls/​src/​Core/​View/​View.cs Synchronizes gestures added during construction.
src/​Controls/​src/​Core/​TypedBinding.cs Honors converter DoNothing results.
src/​Controls/​src/​Core/​Shell/​SearchHandler.cs Implements shared text-style interfaces.
src/​Controls/​src/​Core/​Shell/​RouteRequestBuilder.cs Rejects overlapping or empty route captures.
src/​Controls/​src/​Core/​Shapes/​Shape.cs Preserves custom shape interface dispatch.
src/​Controls/​src/​Core/​Shapes/​LineGeometry.cs Starts line geometry with MoveTo.
src/​Controls/​src/​Core/​PublicAPI/​netstandard/​PublicAPI.Unshipped.txt Records merged-dictionary factory.
src/​Controls/​src/​Core/​PublicAPI/​net/​PublicAPI.Unshipped.txt Records merged-dictionary factory.
src/​Controls/​src/​Core/​PublicAPI/​net-windows/​PublicAPI.Unshipped.txt Records merged-dictionary factory.
src/​Controls/​src/​Core/​PublicAPI/​net-maccatalyst/​PublicAPI.Unshipped.txt Records factory and Apple overrides.
src/​Controls/​src/​Core/​PublicAPI/​net-ios/​PublicAPI.Unshipped.txt Records factory and Apple overrides.
src/​Controls/​src/​Core/​PublicAPI/​net-android/​PublicAPI.Unshipped.txt Records factory and adapter overrides.
src/​Controls/​src/​Core/​Platform/​Windows/​TabbedPage/​TabbedPageStyle.xaml Binds tab accessibility properties.
src/​Controls/​src/​Core/​Platform/​ModalNavigationManager/​ModalNavigationManager.Windows.cs Restores Shell appearance after modal dismissal.
src/​Controls/​src/​Core/​Platform/​iOS/​Extensions/​ButtonExtensions.cs Updates button text without animation.
src/​Controls/​src/​Core/​Platform/​Android/​TabbedViewManager.cs Uses bottom-navigation icon tint fallback.
src/​Controls/​src/​Core/​Platform/​Android/​TabbedPageManager.cs Disables full-page focus highlighting.
src/​Controls/​src/​Core/​Platform/​Android/​LongPressGestureHandler.cs Exposes native clickability internally.
src/​Controls/​src/​Core/​Platform/​Android/​InnerGestureListener.cs Preserves native clicks with long presses.
src/​Controls/​src/​Core/​Platform/​Android/​BottomNavigationViewUtils.cs Supports overflow-row automation identifiers.
src/​Controls/​src/​Core/​Picker/​Picker.cs Avoids redundant selection update loops.
src/​Controls/​src/​Core/​NavigationPage/​NavigationPage.cs Guards appearance events and clears retained toolbars.
src/​Controls/​src/​Core/​MergedStyle.cs Adds applied-style membership lookup.
src/​Controls/​src/​Core/​Menu/​MenuBarItem.cs Rebuilds menus when titles change.
src/​Controls/​src/​Core/​Menu/​MenuBar.cs Adds window menu refresh helper.
src/​Controls/​src/​Core/​Items/​ItemsUpdatingScrollMode.cs Updates scroll-mode documentation.
src/​Controls/​src/​Core/​Handlers/​Shell/​ShellSectionWrapperFragment.Android.cs Guards disconnected handlers during resume.
src/​Controls/​src/​Core/​Handlers/​Shell/​ShellHandler.Windows.cs Restores flyout background when image clears.
src/​Controls/​src/​Core/​Handlers/​Items2/​CollectionViewHandler2.Windows.cs Prevents selection gesture bubbling.
src/​Controls/​src/​Core/​Handlers/​Items2/​CarouselViewHandler2.iOS.cs Prepares controller for scroll requests.
src/​Controls/​src/​Core/​Handlers/​Items/​ItemsViewHandler.Windows.cs Reads ungrouped grid visible indices directly.
src/​Controls/​src/​Core/​Handlers/​Items/​ItemsViewHandler.Android.cs Defers layout requests when necessary.
src/​Controls/​src/​Core/​Handlers/​Items/​iOS/​ObservableGroupedSource.cs Avoids stale section updates during reset.
src/​Controls/​src/​Core/​Handlers/​Items/​CollectionViewHandler.Windows.cs Prevents selection gesture bubbling.
src/​Controls/​src/​Core/​Handlers/​Items/​Android/​ItemsSources/​ObservableItemsSource.cs Returns null for invalid item indices.
src/​Controls/​src/​Core/​Handlers/​Items/​Android/​Adapters/​ReorderableItemsViewAdapter.cs Rejects invalid header/footer drop targets.
src/​Controls/​src/​Core/​Controls.Core.csproj Adds explicit platform package references.
src/​Controls/​src/​Core/​Compatibility/​Handlers/​Shell/​iOS/​ShellTableViewController.cs Exposes cached-view traversal internally.
src/​Controls/​src/​Core/​Compatibility/​Handlers/​Shell/​iOS/​ShellFlyoutHeaderContainer.cs Defers header remeasurement to layout.
src/​Controls/​src/​Core/​BoxView/​BoxView.cs Requests Apple shape redraws on resizing.
src/​Controls/​src/​Core/​BindingExpression.cs Honors converter DoNothing results.
src/​Controls/​src/​Core/​BindingBase.cs Preserves DoNothing through value conversion.
src/​Controls/​src/​Core/​Application/​Application.cs Applies main-page resources through parent handling.
src/​Controls/​src/​Build.Tasks/​XmlTypeExtensions.cs Distinguishes URI mappings from CLR namespaces.
src/​Controls/​src/​Build.Tasks/​nuget/​buildTransitive/​netstandard2.0/​Microsoft.Maui.Controls.Common.targets Exposes preview setting to generators.
src/​Controls/​src/​Build.Tasks/​ExpandMarkupsVisitor.cs Skips unsupported data-type markup expansion.
src/​BlazorWebView/​tests/​DeviceTests/​Elements/​BlazorWebViewTests.Startup.cs Adds startup-test configuration callback.
src/​BlazorWebView/​src/​SharedSource/​Log.cs Adds web-process recovery logging.
src/​BlazorWebView/​src/​Maui/​PublicAPI/​net/​PublicAPI.Unshipped.txt Records process-termination APIs.
src/​BlazorWebView/​src/​Maui/​PublicAPI/​net-windows/​PublicAPI.Unshipped.txt Records process-termination APIs.
src/​BlazorWebView/​src/​Maui/​PublicAPI/​net-maccatalyst/​PublicAPI.Unshipped.txt Records process-termination APIs.
src/​BlazorWebView/​src/​Maui/​PublicAPI/​net-ios/​PublicAPI.Unshipped.txt Records process-termination APIs.
src/​BlazorWebView/​src/​Maui/​PublicAPI/​net-android/​PublicAPI.Unshipped.txt Records process-termination APIs.
src/​BlazorWebView/​src/​Maui/​IBlazorWebView.cs Adds default process-termination callback.
src/​BlazorWebView/​src/​Maui/​BlazorWebViewHandler.cs Forwards process-termination notifications.
src/​BlazorWebView/​src/​Maui/​Android/​WebKitWebViewClient.cs Removes duplicate Content-Type response header.
global.json Updates .NET, Arcade, and Helix pins.
eng/​pipelines/​common/​ui-tests.yml Makes iOS snapshot artifact names unique.
eng/​pipelines/​common/​provision.yml Makes Xcode package installation opt-in.
eng/​pipelines/​arcade/​setup-test-env.yml Disables Xcode package installation by default.
eng/​Build.props Clarifies restore isolation in comments.
docs/​specs/​XamlCSharpExpressions.md Documents global namespace mapping rules.
docs/​design/​FeatureSwitches.md Documents generated XAML line information.
Directory.Build.props Isolates build-task NuGet restore outputs.
.github/​ISSUE_TEMPLATE/​bug-report.yml Adds version 11.0.30 choices.

Review effort: Balanced

Comment on lines +112 to +113
if (element.Handler?.PlatformView is UIMenuElement platformMenuElement)
command.Image = platformMenuElement.Image;
@kubaflo

kubaflo commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/review expert-review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stamping as requested by @kubaflo; no code review performed.

@kubaflo
kubaflo merged commit bca4740 into main Nov 24, 2026
27 of 75 checks passed
@kubaflo
kubaflo deleted the net11 branch November 24, 2026 14:43
@kubaflo
kubaflo restored the net11 branch November 24, 2026 14:47
mattleibow added a commit that referenced this pull request Nov 24, 2026
Resolve the conflicts with main's net11 forward fixes (#40577):

- MauiRecyclerView.cs (Android): when the adapter is replaced, stop both
  main's _itemsUpdateScrollObserver (#39491) and the anchor's
  _scrollAnchorObserver. Adapt the anchor's DataChangeObserver to main's
  Action<bool> callback.
- ItemsViewController2.cs (iOS, Mac Catalyst): in ViewDidLayoutSubviews,
  keep main's InvalidateMeasureIfContentSizeChanged(afterLayout: true)
  (#39882) before the anchor's LayoutFinished. In UpdateItemsSource, keep
  main's CheckForEmptySource before the anchor's Reset, which stays just
  before the offset reset.
- PublicAPI.Unshipped.txt: keep both sides' entries. Both sides added
  ItemsViewController2.ViewDidLayoutSubviews, which is listed once.

While the view follows an edge, ItemsUpdatingScrollMode still doesn't
scroll it, now including main's KeepItemsInView scroll to the first item
(#39491, #39493). While it doesn't, ItemsUpdatingScrollMode applies as
usual, as AnchorMode documents.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
mattleibow added a commit that referenced this pull request Nov 24, 2026
Merging main (#40577) brought #39491 and #39493: KeepItemsInView, the
default ItemsUpdatingScrollMode, now scrolls a list to its first item
as items are added. While the list doesn't follow an edge, AnchorMode
leaves ItemsUpdatingScrollMode to apply as usual, so the tests that
check that only the anchor moves such a list failed with the list at
its first item: 7 cases on Android, and 1 on Mac Catalyst. They now set
KeepScrollOffset, and the AnchorMode remarks say what the default does.

The iOS and Mac Catalyst test helpers GetItemHeight and
GetGroupedItemHeight no longer dispose the index path they look up. It
is the managed peer of UIKit's equal index path, which the handler can
hold while a Scrolled handler calls them. After the merge, the layout an
animated ScrollToEnd forced raised Scrolled while ItemsViewController2
reconfigured the grown row: disposing the shared index path made
InvalidateItems throw NSInvalidArgumentException inside UIKit's layout,
and the Mac Catalyst device-test app crashed later in the run.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
aritchie added a commit to aritchie/maui that referenced this pull request Nov 24, 2026
Resolves conflicts with the net11 forward fixes (dotnet#40577): SetBinding keeps both main's style-binding guard
(dotnet#16569) and the animation hold/claim handling; PublicAPI.Unshipped.txt files take both sides' entries.
@kubaflo kubaflo mentioned this pull request Nov 24, 2026
1 task done
kubaflo added a commit that referenced this pull request Nov 24, 2026
…40582)

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

### Description of Change

Merging #40577 (a manual forward PR whose head was `net11` itself)
caused `delete_branch_on_merge` to delete `net11` and auto-close 29 PRs
targeting it. `net11` was not covered by the existing `MAUI protection`
ruleset (which matches only `net1*.0`).

Remediation already applied to the repository:
- `net11` restored at `3fe3f711a3` (its tip before deletion) and all 29
auto-closed PRs reopened.
- New ruleset **MAUI long-lived branch deletion guard** (deletion rule
only, no bypass) for `net11`, `net12`, `inflight/*`, `candidate/*`.
Verified: deleting a matching probe branch returns HTTP 422 "Cannot
delete this branch".

This PR documents in `docs/ReleaseBranchWorkflow.md` that manual forward
PRs must use a separate `forward/*` head and that the ruleset must stay
in sync with `eng/release-rollover.json`.

Validation: documentation-only; no tests run.

### Issues Fixed

N/A

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 25, 2026
…View in view (#40211)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `0a18c2b26b92e131c5962f1686da929a504392f1`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 7.5/10 | ↑ Merged with `main` at dfca8ad37c, which
moves the repo to .NET 12 (#40060). Only the six Controls PublicAPI
files conflicted, resolved as the exact union of both sides.<br>↑ With
the pinned .NET 12 SDK: Controls.Core builds for net12.0, netstandard2.0
and netstandard2.1 with the PublicAPI analyzers, 0 warnings.
`Controls.Core.UnitTests`: 7033 pass, 30 skipped, including the 108
anchor tests.<br>↑ Each review fix was reproduced by a test that failed
before it.<br>↑ Before this merge, on .NET 11: Android API 37, 300
`CollectionViewTests` pass; Mac Catalyst (macOS 27.2.1), 209 pass.<br>↓
Not built or run locally on .NET 12 for Android, iOS or Mac Catalyst:
this machine has no .NET 12 workloads, and too little free disk to
install them.<br>↓ CI on this head is pending: maui-pr builds every
platform on .NET 12; uitests and devicetests need a maintainer's `/azp
run`.<br>↓ With `main`'s default `KeepItemsInView`, a list the user
scrolled away from jumps to its first item as items are added unless the
app sets `KeepScrollOffset`. |
<!-- /copilot-assessment -->

<!-- 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 new feature with new public API, so it targets `main`.

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

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

Chat, AI-streaming, log and feed screens need a list that keeps one edge
of its content in view while the content changes:
- **The end**, for chats and logs. This includes while the last item
grows in place as an answer streams in.
- **The start**, for feeds that add the newest items at the top.

The list must stop following when the user scrolls away to read, and
start again once they're back at that edge. CollectionView can't do this
today, so every app writes its own scroll tracking. The hard part of
that tracking is telling a user's scroll apart from the platform moving
the offset while rows re-measure.

`ItemsUpdatingScrollMode.KeepLastItemInView` doesn't cover it:
- it only reacts to collection changes;
- it scrolls even while the user reads history;
- it stops at the last item, short of a footer.

Blazor's `Virtualize` added the same capability in .NET 11 for the same
scenarios (`VirtualizeAnchorMode`, dotnet/aspnetcore#65742). This PR
builds the behavior of the dotnet/maui-labs prototype
(dotnet/maui-labs#842) into CollectionView itself, with the same modes
as Blazor.

#### API

```csharp
[Flags]
public enum ScrollAnchorMode
{
    None = 0,   // today's behavior, the default
    Start = 1,  // follow the start: feeds that add the newest items first
    End = 2,    // follow the end: chats, logs, feeds that append
}

public partial class StructuredItemsView
{
    public static readonly BindableProperty AnchorModeProperty;
    public ScrollAnchorMode AnchorMode { get; set; }

    public static readonly BindableProperty IsAnchoredProperty;
    public bool IsAnchored { get; }                   // read-only: whether the view follows an edge right now

    public void ScrollToStart(bool animate = true);   // to the start of the content, header included
    public void ScrollToEnd(bool animate = true);     // to the end of the content, footer included
}
```

The handlers gain `MapAnchorMode` (`CollectionViewHandler2` on iOS and
Mac Catalyst, `StructuredItemsViewHandler<TItemsView>` on Android).
These overrides also show up in `PublicAPI.Unshipped.txt`, because the
anchor listens to the platform's own callbacks:
- `MauiRecyclerView.OnScrolled` and `OnScrollStateChanged`
- `ItemsViewController2.ViewDidLayoutSubviews`
- `ItemsViewDelegator2.DraggingStarted`, `DraggingEnded` and
`DecelerationEnded`

```xml
<CollectionView x:Name="messages" AnchorMode="End" ItemsSource="{Binding Messages}" />
<Button Text="Jump to latest" Clicked="OnJumpToLatest"
        IsVisible="{Binding IsAnchored, Source={x:Reference messages}, Converter={StaticResource InvertedBool}}" />
```

```csharp
void OnJumpToLatest(object sender, EventArgs e) => messages.ScrollToEnd();
```

#### Compared with Blazor's `Virtualize.AnchorMode`

| | Blazor `Virtualize` | `CollectionView` |
| --- | --- | --- |
| Modes | `None`, `Start`, `End`, as flags | the same names and values |
| Default | `Start` | `None`, which keeps today's behavior |
| `Start \| End` | pins both edges; the end wins when the list is at
both | follows whichever edge the view is at, and the end when it's at
both |
| Detecting prepends | `ItemComparer` for `ItemsProvider` sources | not
needed: the anchor measures the content's offset and extent, not items |
| Whether it follows now | not exposed | `IsAnchored`, bindable |
| Back to an edge | the app scrolls the container | `ScrollToStart` and
`ScrollToEnd`, which reach past the header and footer and follow that
edge again |
| Near-edge threshold | 2 px | 8 device-independent units |

#### Behavior

- **`End`:**
  - The view shows the end of its content when it first appears.
  - It keeps the end in view while:
    - items are added or removed;
    - any item grows or shrinks, the last one included;
    - the header or footer changes, in grouped lists too;
    - the viewport resizes.

"The end" means the end of the content, footer included, not the last
item. Following never animates.
- **`Start`** does the same for the start of the content, above the
header. Items inserted before the first item while the view is at its
start come into view instead of landing above it.
- **`Start | End`:**
  - The view starts at the end and follows whichever edge it's at.
  - When it's at both, because its content fits, it follows the end.
- **Changing modes:** Changing `AnchorMode` starts over, as when the
view first appears. Replacing `ItemsSource` or changing `IsGrouped` does
too.
- **Scrolling away:** A user scroll more than 8 device-independent units
away from the edge stops following, and `IsAnchored` becomes `false`. So
does a scroll the user isn't making, such as one from the keyboard,
accessibility, a status-bar tap, or code moving the native view, also
right as a fling or an animated scroll ends. On iOS and Mac Catalyst
17+, a scroll UIKit animates, such as a status-bar tap or code animating
the native view, counts as a fling until it ends, as a smooth scroll
does on Android. None of these stop it:
  - content growing during the gesture;
  - a bounce;
- offset changes the platform makes while laying out, even when the
content ends up the size it started.
- **Scroll requests:**
- A `ScrollTo` from the app is judged by where it lands. Animated, it
carries on as the content changes on the way, and doesn't take the view
back to the edge it left.
  - The latest request wins:
- a `ScrollTo` right after `ScrollToEnd` isn't undone by following the
end;
- a `ScrollTo`, or a change of `AnchorMode`, made from the `Scrolled`
event or the `IsAnchored` change that `ScrollToStart` or `ScrollToEnd`
raises wins over them, also when it turns anchoring off, and so does a
`ScrollTo` from the `Scrolled` event that replacing `ItemsSource`
raises;
- a `ScrollToStart` or `ScrollToEnd` made from the `Scrolled` event that
a `ScrollTo` raises, or from the `RemainingItemsThresholdReached` that a
`ScrollTo` raises as it stops a scroll, wins over that `ScrollTo`;
- a `ScrollToEnd` or `ScrollToStart`, or a change of `AnchorMode` to
`Start` or `End`, right after an animated `ScrollTo` stops that
animation;
- an animated `ScrollToStart` or `ScrollToEnd` right after one to the
other edge that doesn't animate goes to its own edge;
- an animated `ScrollTo` right after a `ScrollToStart`, `ScrollToEnd` or
`ScrollTo` that doesn't animate goes to its item;
- a `ScrollTo` for an index the items don't have, before the first or
past the last, leaves what an earlier scroll is still finishing as it
is.
  - A `ScrollTo` that finds nothing to scroll to changes nothing.
- Reaching the edge again, however the view gets there, starts following
again.
- **`ScrollToStart` and `ScrollToEnd`:**
- They scroll above the header or past the footer, which `ScrollTo(0)`
and `ScrollTo(lastIndex, position: End)` can't reach.
- With the matching mode, the view follows that edge from the moment
it's asked to. "Jump to latest" never sees `IsAnchored` flash `false` on
the way, also while the platform measures the rows an animated one
brings into view. A scroll the user isn't making that stops an animated
one on its way, such as code moving the native view or a status-bar tap,
leaves the view where it stopped, judged as any other scroll. An
animated one to the edge the view is at already doesn't animate, and a
scroll away right after it is judged as any other.
- Without it, they scroll there once. They go the rest of the way once
the rows they brought into view are measured. Animated, they carry on as
the content changes on the way, such as an answer streaming in, and
don't take the view back to the edge it left. A scroll that stops an
animated `ScrollToStart` on its way, such as code moving the native
view, leaves the view where it took it.
  - Like `ScrollTo`, they do nothing before the view has a handler.
- **Turning anchoring off:** Setting `AnchorMode` to `None` stops
following at once, even from a `Scrolled` handler that the anchor's own
correction raised. It isn't a scroll: the view stays where it is, and a
scroll under way, such as an animated `ScrollTo`, carries on. An
animated `ScrollToStart` or `ScrollToEnd` to the edge the view followed
still goes all the way there, as it does without the mode.
- **`ItemsUpdatingScrollMode`:** While the view follows an edge,
`ItemsUpdatingScrollMode` doesn't scroll it. Otherwise that mode applies
as usual, and this PR doesn't change any mode. On `main`,
`KeepItemsInView`, the default, now scrolls the view to its first item
as items are added (#39491, #39493), also a view the user scrolled away
from an edge; `KeepScrollOffset` leaves it where the user scrolled. The
`AnchorMode` remarks say so.

#### How it works

- An internal, platform-agnostic `ScrollAnchorTracker` makes every
decision, following one edge at a time. Its inputs are the offset,
content extent and viewport that the platform reports after each layout
and scroll. Measuring the content extent, rather than tracking items, is
what makes groups, headers, footers and growing items work. The unit
tests spell out its rules.
- The platform code only reads native metrics and scrolls. It uses the
handlers' own signals, with no extra gesture recognizers or external
listeners:
  - **iOS and Mac Catalyst (Items2):**
- Layout: `ItemsViewController2.ViewWillLayoutSubviews` and
`ViewDidLayoutSubviews`. UIKit also lays the view out when the
controller sets a new layout (a header or footer replaced) and when the
items source applies items added, removed or moved. It can move the
offset there before it updates the content size, so the controller
brackets those updates as layout too.
- Scrolling: the `Scrolled`, `DraggingEnded` and `DecelerationEnded`
callbacks on `ItemsViewDelegator2`. A scroll the user isn't making is
judged straight away in `Scrolled`, before the layout pass that measures
the rows it brings into view. It's judged as a new scroll, also right
after a drag, a deceleration or an animated scroll ended, before the
layout pass that looks at where that one stopped. If the content or the
viewport changed size since the anchor last looked, the offset moved for
that change, as when the keyboard manager sets the view's insets, and
it's judged as layout.
- One-shot scrolls: a `ScrollToEnd` without End anchoring finishes in
the layout passes after it, because UIKit estimates rows at 30 points
until it measures them. It finishes only in a layout pass UIKit runs on
its own: one it forces right after the scroll may not have measured the
rows there yet.
- An animated `ScrollToStart` or `ScrollToEnd` to an edge the view
doesn't follow counts as a fling until UIKit reports that its animation
ended, the user drags, or the app requests another scroll, as a
requested smooth scroll does on Android. The anchor used to judge it in
the layout right after the request, before the animation moved the view.
So it followed the edge the view was leaving again, and a row measured,
grown or added before the view got clear of that edge scrolled it back
there, which stopped the animation. UIKit doesn't animate a view that
isn't in a window: it scrolls the view there and reports that the
animation ended before the call returns. The controller counts those
reports, so such a request is done at once, and `ScrollToEnd` goes the
rest of the way as from the end as laid out.
- UIKit keeps the rows in view in place as it measures the rows an
animated scroll to the start brings into view above them, so the
animation stops short of the start by as much as those rows grew. A
one-shot `ScrollToStart` goes the rest of the way once the animation
ends, unless the view stopped further from the start than the content
grew meanwhile, plus 8 units. A scroll stopped the animation then, such
as code moving the native view, and the view stays where that scroll
took it. It used to jump to the start whenever the animation ended.
- A scroll UIKit animates that the anchor didn't start, such as code
animating the native view or a status-bar tap, counts as a fling while
`ScrollAnimating` says it animates (iOS and Mac Catalyst 17+), and the
anchor looks again once UIKit reports its end. It used to be judged as a
scroll the user isn't making: within 8 units of the edge it was leaving,
the view still followed that edge, and a row UIKit measured, or the
content growing, as the animation started took it back there, which
stopped the animation. Before iOS 17 it's judged as before.
- An animated `ScrollTo` counts as a fling the same way while UIKit
animates it. UIKit doesn't animate a scroll to where the item already
is, and never reports an end for it, so the controller checks
`UIScrollView.ScrollAnimating` (iOS and Mac Catalyst 17+) once the
request returns. The anchor used to judge the request in the first
layout, before the animation moved the view: from the end of a list that
follows its end, it kept following the end, and the content changing
then scrolled the view back there, which stopped the animation. Before
iOS 17, which doesn't tell (Mac Catalyst's minimum is 17), it's judged
in the first layout, as before: a content change between that layout and
the animation's first frame still takes the view back to the end there.
- An animated `ScrollToStart` or `ScrollToEnd` to the edge the view
follows keeps following that edge until it gets there. UIKit reports
when its animation ends. An end short of where the animation was going
was a scroll stopping it, such as code moving the native view or a
status-bar tap, unless the anchor's own correction stopped it, UIKit
stopped it while laying the view out, or the content or the viewport
changed size. The anchor then judges where the view stopped. It used to
keep following the edge, so `IsAnchored` stayed `true` and the next
content change pulled the view to the edge. A drag or a newer request
forgets the animation, so the stop that `ScrollToStart` and
`ScrollToEnd` make before they scroll isn't judged.
- An animated `ScrollToStart` or `ScrollToEnd` to the edge the view
follows and is at already doesn't animate, and UIKit reports no end for
it. It now jumps there, as one that doesn't animate does, which judges
where the view is at once. It used to follow the edge as for an
animation on its way there: a scroll away right after it was ignored,
and the rows that scroll brought into view pulled the view back to the
edge.
- A grouped list that measures all its items scrolls to the item again
once an animated `ScrollTo` ends, as on `main`. It now waits for that
end only when UIKit reports one: on iOS and Mac Catalyst 17+ when
`ScrollAnimating` says the scroll animates, and before 17 when the view
is in a window. Otherwise it scrolls again at once. A view that isn't in
a window doesn't animate, and UIKit reports the end before the scroll
returns, so the callback registered after the scroll ran at the end of a
later, unrelated animation, which scrolled back to the item. UIKit never
reports an end for a scroll to where the item already is, either.
- Requests are numbered by the controller. A `ScrollTo`, `ScrollToStart`
or `ScrollToEnd` that a newer request or mode change superseded from its
own `Scrolled` event stops there, also from the layout `ScrollToStart`
and `ScrollToEnd` force before they scroll, and a superseded `ScrollTo`
doesn't arm Mac Catalyst's restore (#34271).
- UIKit records a `scrollToItem` target and applies it again in later
self-sizing layout passes, unless the view really scrolled after
`scrollToItem` returned. So a `ScrollToStart` or `ScrollToEnd` requested
while `ScrollTo` is inside `scrollToItem` runs once it returns.
- Mac Catalyst can move the offset without telling the scroll view
delegate or laying the view out (#34271, #36431). The anchor hears of
that through the `contentOffset` KVO observer `MauiCollectionView`
already has, counts the move as the platform's, and follows its edge
again, replacing the restore of a `ScrollTo` that anchoring clears. The
anchor clears that restore whenever it reports that the view follows an
edge, also when the view got back to it without a drag, as the keyboard
or accessibility scroll it: the restore would otherwise take the view
back to the item when the anchor moves it up as the content shrinks. The
observer tells the controller directly, through a listener it holds
weakly rather than an event, so it doesn't allocate on every scroll
tick.
- While anchored, `LayoutFactory2.FinalizeCollectionViewUpdates` returns
early.
- A mode change stops an animated scroll the app requested, as the view
goes to the edge it now follows. A horizontal layout isn't anchored, so
there a mode change leaves the scroll, the grouped scroll's callback and
Mac Catalyst's restore alone.
- Turning anchoring off while an animated `ScrollToStart` or
`ScrollToEnd` is still on its way to the edge the view followed hands
that scroll to the step that finishes a one-shot scroll once its
animation ends, unless the app requested a newer scroll. Without it, the
scroll stopped where its animation ended, short of an edge that rows
measured on the way had moved.
  - **Android:**
- Signals: `MauiRecyclerView.OnLayout`, `OnScrolled` and
`OnScrollStateChanged`, plus an adapter data observer like the ones
`EmptyView` and `ItemsUpdatingScrollMode` use. RecyclerView keeps the
first row it shows in place as it applies item changes, so the offset
moves even when the content stays the same size. The look after the
layout that applies them counts that move as the layout's. While
anchored, `AdjustScrollForItemUpdate` returns early. The look at a view
whose scroll went idle is posted to the next frame: a scroll reported
before it is judged as a new one, not as the end of the gesture.
- Measuring: RecyclerView's `computeVerticalScrollOffset` and
`computeVerticalScrollRange` are estimates based on the average row
size, so the anchor measures from the laid-out rows instead. The offset
follows a reference row, identified by its view *and* its adapter
position, because RecyclerView reuses a row's view for another row even
within one frame of a fast scroll. Without the first row laid out, the
offset comes from rows laid out before, or from the estimate, which can
be far off with rows of very different heights. A row above the view can
also change size while it isn't laid out: an item replaced, or resized
by a binding, which nothing reports until the row is laid out again. So
the view isn't taken to be at the start until the first row is laid out.
When the first row is laid out again after the offset came from the
estimate, the view moved only as far as the row it kept in view, or the
scroll, says: the anchor tells the tracker that the rest is a new origin
(`ScrollAnchorTracker.MoveOrigin`), not movement. A single scroll away
from the end, by code moving the native view, that first laid out a
first row much taller than the others used to look like a move toward
the end, and the list was pulled back there.
- `ScrollTo` from inside a layout: RecyclerView raises `Scrolled` as it
lays out, and Android drops a layout that a view requests during its own
layout. So a jump requested from there used to land only at some later,
unrelated layout. `ScrollHelper` now requests the layout again once the
current one is over. The adjustment the jump leaves (centering or ending
an item, or reaching the end of a last row taller than the view) waits
for that layout too, instead of running at the end of the current one,
before the jump has scrolled. The anchor judges that request in the
layout that lands it. A correction the anchor has to post the same way,
because the row at the edge isn't laid out yet, leaves the tracker
measuring from where the view was
(`ScrollAnchorTracker.DeferCorrection`), as a scroll can move the view
first: the next look judges that scroll, which stops following the edge
if it took the view away, and otherwise asks for the correction again.
- `ScrollTo(index, groupIndex)` now computes the adapter position from
the group sizes, as the flat index already did. It used to look the item
up one position on (right only for groups with a header) and then search
for an equal item, so it skipped an item, or threw, in groups without a
header, and could land on an equal item in an earlier group. Device
tests call it for a group without a header and for an item equal to one
in an earlier group.
- A `ScrollTo` that doesn't animate, for an index the items don't have
(past the last item, or the header's or footer's position), no longer
replaces a scroll requested before it that hasn't been laid out yet, as
iOS ignores such indices. Animated, it still scrolls there, or to the
last item for an index past it.
- Turning anchoring off while the anchor reports `IsAnchored` stops an
animated scroll to an edge it was about to start. `ScrollToStart` and
`ScrollToEnd` drop a `MandatorySingle` fling's snap target, as
`ScrollTo` does, so the snap doesn't take the view back to it.
- A mode change or a new `ItemsSource` stops an animated scroll the app
requested, all the way to where it ends, as the view goes to the edge it
now follows. RecyclerView's smooth scroller stops once it finds its
target and leaves the rest of the scroll to RecyclerView, which settles
it as it settles a fling, so `IsSmoothScrolling` is `false` for that
last stretch. `MauiRecyclerView` remembers that the scroll is the app's
until the view stops or the user drags it. A fling of the user's still
carries on. On a horizontal layout, which isn't anchored, a mode change
doesn't stop the scroll, and isn't a newer scroll request: a `ScrollTo`
that doesn't animate still jumps to its item when the app changes the
mode from the `RemainingItemsThresholdReached` it raises as it stops a
scroll.
- A new `ItemsLayout` that scrolls vertically after one that didn't
starts the anchor over as `MauiRecyclerView` replaces the layout
manager, as a new view does, rather than at the first look after the
next layout. A `ScrollTo` the app requests right after it, in the same
update, is judged by where it lands, as on iOS and Mac Catalyst, where
the controller looks while it swaps the layout. One requested right
before it was for the layout manager it replaced, and gives way to the
new layout.
- Stopping a scroll raises a pending `RemainingItemsThresholdReached` as
RecyclerView goes idle. A scroll the app requests from it is newer than
the request that stopped the view, so the view doesn't go where that
request was going after it: a mode change, or a `ScrollToStart`,
`ScrollToEnd` or `ScrollTo` that doesn't animate. `ScrollToStart`,
`ScrollToEnd` and a `ScrollTo` that doesn't animate stop the view
themselves before they jump, with or without a matching anchor, because
RecyclerView's `scrollToPosition` would stop it first and then set the
older position.
- An animated `ScrollToStart` or `ScrollToEnd`, with anchoring or
without it, starts once the view is laid out, as iOS lays the view out
before it scrolls. So does one on a horizontal layout, which goes to the
first or last item. RecyclerView's smooth scroller works out how far to
go in the next frame's animation, which comes before that frame's
layout. So a row the app grew with the request moved the end after the
scroll had stopped, and nothing followed it. And a jump to the other
edge that an earlier request left for that layout landed after the
smooth scroller had already stopped, having found its target in place.
The request waits where `ScrollHelper` keeps a jump's adjustment, so a
newer request replaces it. A mode change to `Start` or `End` cancels it,
and the adjustment a jump left, as it stops an animated scroll the app
requested.
- An animated `ScrollTo` whose item is already in place doesn't scroll:
the smooth scroller stops in its first step, and nothing reports that.
The anchor judged the request only at the next content change, after the
change had moved the content, and stopped following the edge the view
was at. It now looks once the smooth scroller has taken its first step,
which judges such a request where the view is, and one that scrolls as a
fling.
- An animated `ScrollTo` for an item starts once the view is laid out
while a jump hasn't been made yet: one from `ScrollToStart`,
`ScrollToEnd` or a `ScrollTo` that doesn't animate, or the anchor's jump
to its edge. RecyclerView makes the jump in the next layout, and the
smooth scroller's first step comes before it: finding the item the view
showed in place, it stopped, and the jump then took the view away.
`ScrollHelper` and the anchor record a jump until that layout. A
`ScrollTo` past the last item, as `KeepLastItemInView` requests, starts
at once as before.
- `ScrollToStart` and `ScrollToEnd` reach the platform through an
internal `IScrollToEdgeHandler`. Where the view can't scroll to an edge
of its content, the handler scrolls to the first or last item it shows,
grouped or not. It finds that item in its own items (the adapter, the
collection view's sections, or WinUI's `CollectionViewSource`), not by
reading `ItemsSource` again, so a sequence that can be read only once
and groups that aren't lists work. Only handlers without the interface
(the obsolete iOS handler, the opt-out Windows `CollectionViewHandler`,
custom handlers) fall back to `ScrollTo` the first or last item
`ItemsSource` gives.

| Platform | `AnchorMode` `Start` and `End` | `ScrollToStart` and
`ScrollToEnd` |
| --- | --- | --- |
| iOS, Mac Catalyst (Items2, the default handler) | vertical layouts |
edges of the content |
| Android | vertical layouts | edges of the content |
| Windows (Items2, the default handler) | not implemented, `IsAnchored`
stays `false` | first and last item (unverified) |
| iOS legacy handler (opt-in) | not implemented | first and last item |
| Horizontal layouts | not anchored | first and last item |

#### Tests

- **Unit tests** (`Controls.Core.UnitTests`): 108/108 pass on .NET 12,
after merging `main` at dfca8ad37c. The whole project passes too: 7033
tests, 30 skipped.
  - 83 tracker tests spell out the rules for both edges.
  - 25 cover the API:
    - `AnchorMode` and `IsAnchored`;
    - how `ScrollToStart` and `ScrollToEnd` reach the handler;
- their `ScrollTo` fallback, grouped lists, and calls without a handler,
which don't read `ItemsSource`.
- **Device tests** (`CollectionViewTests.ScrollAnchor.cs`): 145 cases
run on Android, 142 on iOS and 144 on Mac Catalyst, as some are
platform-specific. They last ran locally on .NET 11, before the merge of
`main` at dfca8ad37c moved the branch to .NET 12; CI runs them on .NET
12. Each review fix was first reproduced without the fix, by a device
test, a unit test, or a scripted check on Mac Catalyst. In the latest
rounds, on the Android emulator unless noted:
- A new test of 2 cases turns a horizontal `End` list vertical and
requests `ScrollTo(10)` right after it, or right before it, in the same
update. Before the change, the case with the request after the switch
failed on Android: item 10 never came into view, as the anchor started
over at its first look after the layout and dropped the request. Both
cases pass on Android and Mac Catalyst.
- Merging `main` (#40577): with #39491 and #39493, `KeepItemsInView`,
the default `ItemsUpdatingScrollMode`, scrolls a list that doesn't
follow an edge to its first item as items are added. 5 tests (9 cases)
check that only the anchor moves such a list, and 8 of those cases
failed with the list at its first item: 7 on Android, and 1 of the 2 Mac
Catalyst cases of another, whose other case passed only because the list
went to its start, away from its end. The 5 tests now set
`KeepScrollOffset`, and pass.
- After the merge, the Mac Catalyst device-test app crashed 3 times in 3
runs (SIGBUS and SIGSEGV in UIKit's observation tracking, during
layout). The first managed failure was an `NSInvalidArgumentException`
("attempt to insert nil object") from `InvalidateItems` in
`ItemsViewController2.InvalidateLayoutIfItemsMeasureChanged`, inside the
layout an animated `ScrollToEnd` forced. The test helpers
`GetItemHeight` and `GetGroupedItemHeight`, called from a `Scrolled`
handler in that layout, disposed the index path they looked up: the
managed peer of UIKit's equal index path, which the handler held for
`InvalidateItems`. They no longer dispose it; the class then passes. The
pre-merge head passed on the same machine (macOS 27.2.1), so the merged
layout timing exposed it.
- On Android, a new test opens an `End` list whose first row is 1000
high and whose other 110 rows are 3 high, so at the end the first row
sits just above the view, measured only by RecyclerView's estimate. Code
then scrolls the native view up 100, which lays that row out. Before the
change, the list was pulled back to its end: the first row at -2455 px
right after the scroll, then row 12 at the top. Two new tracker tests (3
cases) cover `MoveOrigin`; all 3 fail with it doing nothing.
- On Android, a new test of 2 cases (`None`, `Start`) has a
`ScrollTo(5)` that doesn't animate stop an animated scroll on a
horizontal list, and the app changes `AnchorMode` to `End` from the
`RemainingItemsThresholdReached` that stopping raises. Before the
change, both failed: the mode change dropped the jump, and item 5 never
came into view.
- On iOS and Mac Catalyst, a new test of 2 cases calls an animated
`ScrollToStart` or `ScrollToEnd` on a list at that edge, and then has
code scroll the native view 200 away from it. Before the change, both
failed on Mac Catalyst, with the list pulled back to the edge.
- On iOS and Mac Catalyst, a new test of 4 cases (`None` or `End`, the
scroll animated or not) has code scroll the native view to 100 short of
the end right after an animated `ScrollToStart` from the end. Before the
change, both animated cases failed on Mac Catalyst: the jump to the
start overrode that scroll, and the list never got to 100 short of its
end. The others passed before too: UIKit reports the end of an animation
that a scroll without animating stops before it applies that scroll. The
test allows for UIKit moving the end further away as it measures the
rows the scroll brought into view, which once left the list 230 short of
the end, with the offset where the scroll put it.
- That test's animated `End` case also failed in 5 or 6 of 10 repeats,
for a race this round fixes: a row UIKit measured while the view was
still within 8 units of the end took the view back there. A new test
grows the last row as code starts animating the native view of an `End`
list 100 short of the end. Before the change, the list was back at the
end and still anchored in each of 3 tries on Mac Catalyst. Now it ends
where a list without anchoring does: 130 short of the end on macOS 27,
as UIKit measures the rows above again. All 10 repeats of the race pass.
CI's Mac Catalyst run on macOS 26 ended that test 360 short of the end,
where it had checked for at most 300: UIKit there measures the rows
above differently, and iOS 26 and macOS 15 passed it. The anchor only
ever scrolls a list that follows its end to the end, so the test now
checks that the list stays away from both edges (less than half the
scroll range from the end) rather than how far UIKit takes the end.
- The test of a `ScrollToEnd` from `Scrolled` as `ScrollToStart` goes
the rest of the way used to fake UIKit's report that the animation
ended, right after the request, with the list still at the end. It now
lets UIKit stop the animation short of the start: 200 short on Mac
Catalyst, as rows are estimated at 30 and measure 40.
- A new Android test of 4 cases (`ScrollToStart` or `ScrollToEnd`, with
a matching anchor or none) stops an animated scroll past the
`RemainingItemsThresholdReached` threshold with a `ScrollTo(20)` that
doesn't animate, and calls `ScrollToStart` or `ScrollToEnd` from that
event. Before the change, both cases without an anchor failed: the older
`ScrollTo` won, with row 13 at the top, or the end out of view. With a
matching anchor they passed before too, as the anchor's reset takes the
view to its edge.
- On iOS and Mac Catalyst, a new test of 2 cases stops an animated
`ScrollToEnd` on its way with a native scroll back to the start, without
animating, or animated as a status-bar tap does. Before the change, both
failed on the iPhone 18 Pro simulator: the list stayed at its start, but
`IsAnchored` stayed `true`.
- On iOS and Mac Catalyst, a new test of 2 cases (`End`, `MakeVisible`)
makes an animated `ScrollTo` in a grouped list that measures all its
items while the list is out of its window, and then scrolls the native
view back toward the start, animated. Before the change, both failed on
the iPhone 18 Pro simulator: as that animation ended, the list scrolled
back to the item, 1006 from the start (878 when it first showed the
item). UIKit stops that animation short of the start, as it measures the
rows above that the jump skipped, so the test checks that the list
doesn't go back to the item rather than that it reaches the start.
- A new test of 2 cases calls `ScrollToEnd(false)` and then an animated
`ScrollToStart` on a horizontal list at its start, and the reverse.
Before the change, both failed on Android, with the list at the edge it
jumped to. iOS and Mac Catalyst passed before the change too.
- A new test of 4 cases (every `AnchorMode`) calls `ScrollToEnd(false)`
and then an animated `ScrollTo(0)` on a list at its start. Before the
change, all 4 failed on Android with the list at the end (row 32 at the
top), including End and Start | End, where the jump was the anchor's.
iOS and Mac Catalyst passed before the change too.
- On iOS and Mac Catalyst, a new test insets the bottom of an End list
by 300 and scrolls the native view up 200 outside a layout pass, as the
keyboard manager does. The anchor judges that as layout and keeps the
end in view. With the `IsResized` veto removed, it failed on the iPhone
18 Pro simulator: 530 from the end, no longer following it.
- On iOS and Mac Catalyst, a new test has code scroll the native view up
200 right after UIKit reports that an animated scroll ended, before the
layout pass that follows. UIKit reports the end of a drag, a
deceleration or an animated scroll before that pass, and the anchor took
a scroll in between for the end of the one that ended. Before the
change, the list was pulled back to its end on the iPhone 18 Pro
simulator, 0 from the end. A new tracker test covers `IsResized`: an
offset move that comes with a size change is still judged as layout.
- On Mac Catalyst, back at the end of an End list after a `ScrollTo(0)`
that doesn't animate, through native scrolls that aren't drags, a new
test shrinks the last item. Before the change, the restore that
`ScrollTo` armed took the list back to its first item: 30 from the
start, 1100 from the end, not anchored.
- A native scroll up 200 from a scroll listener as a short fling goes
idle, before the anchor's posted look, has a new test. Before the
change, the list was pulled back to its end. Two new tracker tests cover
it: the original code took the view back to the edge, and gating the
gesture-end exemption alone stopped following for a scroll toward the
end.
- Code scrolling the native view up 200 from the GlobalLayout callback
after items are appended, before the anchor's posted jump to the new end
lands, has a new test. Before the change, the list jumped from row 27,
where the scroll left it, to the end at row 52. It passes now, and with
`DeferCorrection` resetting the tracker as before, the 2 new tracker
tests of a scroll away fail.
- An animated `ScrollTo` to the first item, from the end of a list that
follows only its end, has a new test of 2 cases: the last row grows, or
an item is added, once the list is laid out for the request and before
the animation moves it. Before the change, both failed with the list
back at the end: 1040 and 1120 from the start on the iPhone 18 Pro
simulator, 1170 and 1200 on Mac Catalyst. Android needed no change for
them. A new test of an animated `ScrollTo` to where the last item
already is failed on Android before the change: once the last row grew,
the list had stopped following, 80 short of the end. All 3 cases pass on
Android, iOS and Mac Catalyst now.
- CI's Mac Catalyst run on macOS 26 left an animated `ScrollToStart`
from the end of a list that follows only its end at the end, 1220 from
the start, in one of its two runs. A new test of 2 cases grows the last
row, or adds an item, once the list is laid out for the request and
before the animation moves it. Before the change, both failed on the
iPhone 18 Pro simulator and on Mac Catalyst, with the list back at the
end: 1220 from the start for the grown row on Mac Catalyst, as in CI.
Both pass on Android, iOS and Mac Catalyst now. Android needed no
change.
- A throwaway probe on the iPhone 18 Pro simulator showed that UIKit
reports the end of a scroll animation in every case it tried: one that
finishes, one a scroll stops, the view leaving its window, an inset,
content size or visibility change. A view that isn't in a window doesn't
animate: UIKit scrolls it and reports the end before the call returns. A
new iOS and Mac Catalyst test of 2 cases takes the list out of its
window for an animated `ScrollToStart` or `ScrollToEnd`. Before the
change, the `ScrollToStart` case failed on the iPhone 18 Pro simulator:
back at its end, the list didn't follow a new item, 40 short of the end.
Both pass on iOS and Mac Catalyst now.
- An animated `ScrollToStart` or `ScrollToEnd` right after one to the
other edge that doesn't animate, on a list settled at the edge the
animated one goes to, has a new test of 16 cases: every `AnchorMode`,
both edges, and with or without a header and footer. Before the change,
6 failed. The animated `ScrollToStart` that the view doesn't follow
(`AnchorMode` `None` or `End`) left the list at the end. With rows of
one height and no header or footer, an anchored `ScrollToStart` or
`ScrollToEnd` left it at the other edge too. All 16 pass on Android, iOS
and Mac Catalyst now.
- With the data-item check removed, a `ScrollTo` that doesn't animate,
for the footer's index (`items.Count`) or the header's (-1), right after
`ScrollToEnd(false)` cancelled the adjustment that finishes it: the list
stopped 299.8 and 350.1 short of the end.
- iPhone 18 Pro simulator: without the handover, turning `AnchorMode`
off during an animated `ScrollToEnd` or `ScrollToStart` to the edge the
list followed left it 230 short of the end and 130 from the start.
Android reached the edge either way.
- The check that scrolling the native view away as an item is added
stops following the end now runs on iOS and Mac Catalyst too. It passes
there unchanged: UIKit resizes the content as the item is inserted,
which the anchor looks at before the scroll.
- With the request check across the stop removed, a `ScrollTo` requested
from the `RemainingItemsThresholdReached` that stopping a scroll raises
lost to the edge the list went to: for a mode change, and for
`ScrollToEnd` and `ScrollToStart` that don't animate. Without stopping
the view before the jump, all four `ScrollToEnd` and `ScrollToStart`
cases failed, with a matching anchor and without one.
- With the horizontal check removed, both cases of the new test of a
mode change during an animated `ScrollTo` on a horizontal list failed.
On Android the scroll stopped and never reached the item. On the iPhone
18 Pro simulator it stopped too, and UIKit then put the view at the item
in a single jump at the next layout, so the test also checks that the
scroll keeps animating.
- Without the change to the animated `ScrollToEnd`, both cases of its
new test failed, with the last row grown before the request or after it:
the footer stayed out of view.
- CI's Mac Catalyst run on macOS 26 ended the case that grows the row
after the request 50 short of the end, in one of its two runs. iOS and
Mac Catalyst lay the view out as `ScrollToEnd` is called, and follow a
row grown after it only while UIKit measures the rows the scroll brought
into view (see open question 11), so that case runs on Android only.
Both cases check that the view reached the end of the grown row, as the
test of a row measured in a later layout does.
- With `main`'s lookup for `ScrollTo(index, groupIndex)` restored, both
of the new direct calls failed: one threw `ArgumentOutOfRangeException`
for a group without a header, and the other scrolled to the equal item
of the first group.
- With the anchor's stop left as it was, the case of a mode change right
after an animated `ScrollToEnd` failed: the scroll waiting for the
layout still took the list to the end.
- Android API 37 emulator, after merging `main` at bca4740888 (.NET 11):
all 300 `CollectionViewTests` pass, with 1 skip that predates this PR.
- Mac Catalyst (macOS 27.2.1), after merging `main` at bca4740888 (.NET
11): all 209 `CollectionViewTests` pass, with 4 skips that predate this
PR. The latest local iOS run (iOS 27.2) is of an earlier head: all 170
passed. CI's iOS stages, on macOS 15 and macOS 26 hosts, passed every
anchor test on 42c1a3060d. Each has 4 skips that predate this PR. The
Xcode 27.2 SDK requires a scene manifest in the device-test app
(MT7199), so these ran with one added locally. It isn't part of this PR.
- The horizontal cases wait until the list is laid out before they
scroll: before that, a list is at both of its edges, and they passed on
iOS without scrolling.
- CI's device tests on iOS 26 and macOS 26 found failures that iOS 27
and macOS 27 don't show. This head addresses them:
- UIKit moved the offset before it updated the content size, while it
updated the view for a new layout (a replaced header or footer) or for
removed items. The controller now brackets those updates as layout.
- Rows measured during an animated `ScrollToStart` moved the offset away
from the start before any size change was reported. An animated scroll
to an edge now follows that edge until it gets there.
- A one-shot `ScrollToEnd` that doesn't animate finished in the layout
passes it forced, before UIKit measured the rows there. It now finishes
only in a layout pass UIKit runs on its own.

The replaced header and the one-shot `ScrollToEnd` failed locally too,
and pass now. New unit tests cover following an edge on the way there,
and a new device test covers the one-shot `ScrollToEnd`. Only CI can
confirm the fixes on iOS 26 and macOS 26.
- **UI tests** (`CollectionViewAnchorModeEnd`, 3 tests). They cover
following added and growing items, scrolling away and back, and
`ScrollTo` away from the end followed by `ScrollToEnd`. The growing-item
test waits until the last message has grown before it checks that the
footer is in view. Their waits find a row again when the list recycled
it between finding it and reading its geometry.
  - 3/3 on an iPhone 18 Pro simulator (iOS 27.2) with real touch.
  - 3/3 on an Android API 37 emulator.
- **Mac Catalyst and the iPhone 18 Pro simulator:** local scripted
checks of the scenarios above all pass. They include:
  - 32/32 repeated one-shot `ScrollToEnd` runs on each;
- a `ScrollTo` from `Scrolled` or from `IsAnchored` during
`ScrollToEnd`, or from `Scrolled` as `ItemsSource` is replaced;
- a mode change during an animated `ScrollTo`, including before its
first frame;
  - `KeepLastItemInView` with `Start`;
- the restore armed by a `ScrollTo` that doesn't animate. With the two
clears removed, the list goes back to that item.
- **Not run locally:**
- Catalyst UI tests: on this machine Appium loses the app at launch for
any test page, including existing ones.
  - iOS 26 and macOS 26, which only CI has.

<details>
<summary>Commands</summary>

```bash
# Unit tests: 108 passed
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj \
  --filter "FullyQualifiedName~ScrollAnchorTrackerTests|FullyQualifiedName~StructuredItemsViewAnchorModeTests"

# UI tests, with the HostApp installed on the device: 3 passed on each
DEVICE_UDID=<simulator udid> dotnet test src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj \
  --filter "FullyQualifiedName~CollectionViewAnchorModeEnd"
DEVICE_UDID=emulator-5554 dotnet test src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj \
  --filter "FullyQualifiedName~CollectionViewAnchorModeEnd"

# Android device tests: 300 passed, 1 skipped (on .NET 11, before the merge that moved the branch to .NET 12)
EmbedAssembliesIntoApk=true pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls \
  -Platform android -Configuration Debug -IncludeClasses "Microsoft.Maui.DeviceTests.CollectionViewTests" -BuildOnly
dotnet xharness android test \
  --app artifacts/bin/Controls.DeviceTests/Debug/net12.0-android/com.microsoft.maui.controls.devicetests-Signed.apk \
  --package-name com.microsoft.maui.controls.devicetests \
  --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation \
  --device-id emulator-5554 -o artifacts/log/anchor-android --timeout 00:45:00

# iOS device tests (with a local scene manifest): 170 passed, 4 skipped, on an earlier head. Mac Catalyst: 209 passed,
# 4 skipped. Both ran on .NET 11. For Mac Catalyst, use -f net12.0-maccatalyst -r maccatalyst-arm64 and --target maccatalyst.
dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Debug -f net12.0-ios -r iossimulator-arm64
dotnet xharness apple test \
  --app artifacts/bin/Controls.DeviceTests/Debug/net12.0-ios/iossimulator-arm64/Microsoft.Maui.Controls.DeviceTests.app \
  --target ios-simulator-64_27.2 --device <simulator udid> -o artifacts/log/anchor-ios --timeout 00:40:00 \
  --set-env=NUNIT_SKIPPED_CLASSES=Microsoft.Maui.DeviceTests.CollectionViewTests
```

</details>

#### Open questions for API review

1. **Names.** `ScrollAnchorMode` or `ItemsAnchorMode`? I chose
`ScrollAnchorMode` so a vertical `ScrollView` can reuse it later; the
same tracker already works for one. `AnchorMode` matches Blazor, but it
sits next to `VisualElement.AnchorX` and `AnchorY`, which are transform
anchors.
2. **Default.** It's `None`, so existing apps don't change. Blazor's
default is `Start`.
3. **`IsAnchored`** is a `bool` for either edge. Should it say which
edge the view follows, for `Start | End`?
4. **Changing `AnchorMode`** shows the edge it selects. Blazor doesn't
scroll when the mode changes.
5. **Threshold.** The 8-unit threshold is fixed and internal; Blazor
uses 2 px.
6. **Windows:** `AnchorMode` isn't implemented, because it can't be
verified on a Mac. WinUI's `VerticalAnchorRatio` may fit.
`ScrollToStart` and `ScrollToEnd` scroll to the first and last item the
default handler shows, but that's unverified too: the WinUI XAML
compiler doesn't run on macOS, so it hasn't even been compiled here.
7. **Horizontal layouts and right-to-left** aren't anchored.
8. **Snap points.** With mandatory snap points, `ScrollToEnd` ends at
the nearest snap point, as `ScrollTo` does. On Android, `ScrollToStart`
and `ScrollToEnd` drop the item a `MandatorySingle` fling snapped to, as
`ScrollTo` does, so the snap doesn't take the view back to it. Anchoring
isn't designed for snapping lists.
9. **Mac Catalyst's silent offset clamp (#34271).** It doesn't reproduce
on this machine, through a Picker, minimizing and restoring, or a
resize. The anchor still hears of an offset change only KVO reports, and
follows its edge again: a device test simulates one by moving the
layer's bounds with manual KVO notifications.
10. **Overlap with `ItemsUpdatingScrollMode`** (#39491 and #39493, now
in `main`). While the view follows an edge, the anchor keeps it there:
`AdjustScrollForItemUpdate` on Android and
`FinalizeCollectionViewUpdates` on iOS and Mac Catalyst return early.
Otherwise `ItemsUpdatingScrollMode` applies as before. Its default,
`KeepItemsInView`, scrolls the list to its first item as items are
added, so an `End` list the user scrolled away from jumps to its first
item unless the app sets `KeepScrollOffset`. Should `AnchorMode` keep
the offset while the view doesn't follow an edge?
11. **One-shot `ScrollToEnd` without End anchoring** scrolls once. On
Mac Catalyst with accessibility active, UIKit measures rows above the
view 100 to 300 ms after a scroll without keeping the content in place,
which can leave the view 80 to 100 short of the end. After a row
resizes, UIKit also lays offscreen rows and the header out at their
estimated size and measures them again later, which can leave it 30
short. Both are Items2 behavior that predates this PR, and the device
tests allow for them. Should a one-shot `ScrollToEnd` hold the end until
something else scrolls the view, as UIKit holds a `scrollToItem` target?
Or should Items2 keep the content in view in place as UIKit measures
rows above it, for every scroll?
12. **Turning anchoring off** doesn't stop a scroll under way; a review
suggested it should. It isn't a scroll, and stopping one would make
`ScrollTo(item, animate: true); AnchorMode = None;` drop the scroll
while the reverse order keeps it. An animated `ScrollToStart` or
`ScrollToEnd` to the edge the view followed still goes all the way
there. A change to `Start` or `End` does stop it, as it scrolls to that
edge, except on a horizontal layout, which isn't anchored.

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

N/A: this is a new feature, and it doesn't fully fix any open issue.
Related:

- #35802 (KeepLastItemInView does nothing on .NET 10 iOS and Android):
not fixed here. `AnchorMode="End"` is the alternative for chats.
- #12036, #29153 (grouped lists): `AnchorMode="End"` follows grouped
lists. This PR doesn't change `KeepLastItemInView`; `main` has since
fixed #29153 (#39491, #39493).
- #29420 (CarouselView): out of scope, because CarouselView isn't a
`StructuredItemsView`.

<!--
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>
Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…otnet#40582)

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

### Description of Change

Merging dotnet#40577 (a manual forward PR whose head was `net11` itself)
caused `delete_branch_on_merge` to delete `net11` and auto-close 29 PRs
targeting it. `net11` was not covered by the existing `MAUI protection`
ruleset (which matches only `net1*.0`).

Remediation already applied to the repository:
- `net11` restored at `3fe3f711a3` (its tip before deletion) and all 29
auto-closed PRs reopened.
- New ruleset **MAUI long-lived branch deletion guard** (deletion rule
only, no bypass) for `net11`, `net12`, `inflight/*`, `candidate/*`.
Verified: deleting a matching probe branch returns HTTP 422 "Cannot
delete this branch".

This PR documents in `docs/ReleaseBranchWorkflow.md` that manual forward
PRs must use a separate `forward/*` head and that the ruleset must stay
in sync with `eng/release-rollover.json`.

Validation: documentation-only; no tests run.

### Issues Fixed

N/A

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
…View in view (dotnet#40211)

<!-- copilot-assessment:v1 -->
### Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: `0a18c2b26b92e131c5962f1686da929a504392f1`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 7.5/10 | ↑ Merged with `main` at dfca8ad37c, which
moves the repo to .NET 12 (#40060). Only the six Controls PublicAPI
files conflicted, resolved as the exact union of both sides.<br>↑ With
the pinned .NET 12 SDK: Controls.Core builds for net12.0, netstandard2.0
and netstandard2.1 with the PublicAPI analyzers, 0 warnings.
`Controls.Core.UnitTests`: 7033 pass, 30 skipped, including the 108
anchor tests.<br>↑ Each review fix was reproduced by a test that failed
before it.<br>↑ Before this merge, on .NET 11: Android API 37, 300
`CollectionViewTests` pass; Mac Catalyst (macOS 27.2.1), 209 pass.<br>↓
Not built or run locally on .NET 12 for Android, iOS or Mac Catalyst:
this machine has no .NET 12 workloads, and too little free disk to
install them.<br>↓ CI on this head is pending: maui-pr builds every
platform on .NET 12; uitests and devicetests need a maintainer's `/azp
run`.<br>↓ With `main`'s default `KeepItemsInView`, a list the user
scrolled away from jumps to its first item as items are added unless the
app sets `KeepScrollOffset`. |
<!-- /copilot-assessment -->

<!-- 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 new feature with new public API, so it targets `main`.

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

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

Chat, AI-streaming, log and feed screens need a list that keeps one edge
of its content in view while the content changes:
- **The end**, for chats and logs. This includes while the last item
grows in place as an answer streams in.
- **The start**, for feeds that add the newest items at the top.

The list must stop following when the user scrolls away to read, and
start again once they're back at that edge. CollectionView can't do this
today, so every app writes its own scroll tracking. The hard part of
that tracking is telling a user's scroll apart from the platform moving
the offset while rows re-measure.

`ItemsUpdatingScrollMode.KeepLastItemInView` doesn't cover it:
- it only reacts to collection changes;
- it scrolls even while the user reads history;
- it stops at the last item, short of a footer.

Blazor's `Virtualize` added the same capability in .NET 11 for the same
scenarios (`VirtualizeAnchorMode`, dotnet/aspnetcore#65742). This PR
builds the behavior of the dotnet/maui-labs prototype
(dotnet/maui-labs#842) into CollectionView itself, with the same modes
as Blazor.

#### API

```csharp
[Flags]
public enum ScrollAnchorMode
{
    None = 0,   // today's behavior, the default
    Start = 1,  // follow the start: feeds that add the newest items first
    End = 2,    // follow the end: chats, logs, feeds that append
}

public partial class StructuredItemsView
{
    public static readonly BindableProperty AnchorModeProperty;
    public ScrollAnchorMode AnchorMode { get; set; }

    public static readonly BindableProperty IsAnchoredProperty;
    public bool IsAnchored { get; }                   // read-only: whether the view follows an edge right now

    public void ScrollToStart(bool animate = true);   // to the start of the content, header included
    public void ScrollToEnd(bool animate = true);     // to the end of the content, footer included
}
```

The handlers gain `MapAnchorMode` (`CollectionViewHandler2` on iOS and
Mac Catalyst, `StructuredItemsViewHandler<TItemsView>` on Android).
These overrides also show up in `PublicAPI.Unshipped.txt`, because the
anchor listens to the platform's own callbacks:
- `MauiRecyclerView.OnScrolled` and `OnScrollStateChanged`
- `ItemsViewController2.ViewDidLayoutSubviews`
- `ItemsViewDelegator2.DraggingStarted`, `DraggingEnded` and
`DecelerationEnded`

```xml
<CollectionView x:Name="messages" AnchorMode="End" ItemsSource="{Binding Messages}" />
<Button Text="Jump to latest" Clicked="OnJumpToLatest"
        IsVisible="{Binding IsAnchored, Source={x:Reference messages}, Converter={StaticResource InvertedBool}}" />
```

```csharp
void OnJumpToLatest(object sender, EventArgs e) => messages.ScrollToEnd();
```

#### Compared with Blazor's `Virtualize.AnchorMode`

| | Blazor `Virtualize` | `CollectionView` |
| --- | --- | --- |
| Modes | `None`, `Start`, `End`, as flags | the same names and values |
| Default | `Start` | `None`, which keeps today's behavior |
| `Start \| End` | pins both edges; the end wins when the list is at
both | follows whichever edge the view is at, and the end when it's at
both |
| Detecting prepends | `ItemComparer` for `ItemsProvider` sources | not
needed: the anchor measures the content's offset and extent, not items |
| Whether it follows now | not exposed | `IsAnchored`, bindable |
| Back to an edge | the app scrolls the container | `ScrollToStart` and
`ScrollToEnd`, which reach past the header and footer and follow that
edge again |
| Near-edge threshold | 2 px | 8 device-independent units |

#### Behavior

- **`End`:**
  - The view shows the end of its content when it first appears.
  - It keeps the end in view while:
    - items are added or removed;
    - any item grows or shrinks, the last one included;
    - the header or footer changes, in grouped lists too;
    - the viewport resizes.

"The end" means the end of the content, footer included, not the last
item. Following never animates.
- **`Start`** does the same for the start of the content, above the
header. Items inserted before the first item while the view is at its
start come into view instead of landing above it.
- **`Start | End`:**
  - The view starts at the end and follows whichever edge it's at.
  - When it's at both, because its content fits, it follows the end.
- **Changing modes:** Changing `AnchorMode` starts over, as when the
view first appears. Replacing `ItemsSource` or changing `IsGrouped` does
too.
- **Scrolling away:** A user scroll more than 8 device-independent units
away from the edge stops following, and `IsAnchored` becomes `false`. So
does a scroll the user isn't making, such as one from the keyboard,
accessibility, a status-bar tap, or code moving the native view, also
right as a fling or an animated scroll ends. On iOS and Mac Catalyst
17+, a scroll UIKit animates, such as a status-bar tap or code animating
the native view, counts as a fling until it ends, as a smooth scroll
does on Android. None of these stop it:
  - content growing during the gesture;
  - a bounce;
- offset changes the platform makes while laying out, even when the
content ends up the size it started.
- **Scroll requests:**
- A `ScrollTo` from the app is judged by where it lands. Animated, it
carries on as the content changes on the way, and doesn't take the view
back to the edge it left.
  - The latest request wins:
- a `ScrollTo` right after `ScrollToEnd` isn't undone by following the
end;
- a `ScrollTo`, or a change of `AnchorMode`, made from the `Scrolled`
event or the `IsAnchored` change that `ScrollToStart` or `ScrollToEnd`
raises wins over them, also when it turns anchoring off, and so does a
`ScrollTo` from the `Scrolled` event that replacing `ItemsSource`
raises;
- a `ScrollToStart` or `ScrollToEnd` made from the `Scrolled` event that
a `ScrollTo` raises, or from the `RemainingItemsThresholdReached` that a
`ScrollTo` raises as it stops a scroll, wins over that `ScrollTo`;
- a `ScrollToEnd` or `ScrollToStart`, or a change of `AnchorMode` to
`Start` or `End`, right after an animated `ScrollTo` stops that
animation;
- an animated `ScrollToStart` or `ScrollToEnd` right after one to the
other edge that doesn't animate goes to its own edge;
- an animated `ScrollTo` right after a `ScrollToStart`, `ScrollToEnd` or
`ScrollTo` that doesn't animate goes to its item;
- a `ScrollTo` for an index the items don't have, before the first or
past the last, leaves what an earlier scroll is still finishing as it
is.
  - A `ScrollTo` that finds nothing to scroll to changes nothing.
- Reaching the edge again, however the view gets there, starts following
again.
- **`ScrollToStart` and `ScrollToEnd`:**
- They scroll above the header or past the footer, which `ScrollTo(0)`
and `ScrollTo(lastIndex, position: End)` can't reach.
- With the matching mode, the view follows that edge from the moment
it's asked to. "Jump to latest" never sees `IsAnchored` flash `false` on
the way, also while the platform measures the rows an animated one
brings into view. A scroll the user isn't making that stops an animated
one on its way, such as code moving the native view or a status-bar tap,
leaves the view where it stopped, judged as any other scroll. An
animated one to the edge the view is at already doesn't animate, and a
scroll away right after it is judged as any other.
- Without it, they scroll there once. They go the rest of the way once
the rows they brought into view are measured. Animated, they carry on as
the content changes on the way, such as an answer streaming in, and
don't take the view back to the edge it left. A scroll that stops an
animated `ScrollToStart` on its way, such as code moving the native
view, leaves the view where it took it.
  - Like `ScrollTo`, they do nothing before the view has a handler.
- **Turning anchoring off:** Setting `AnchorMode` to `None` stops
following at once, even from a `Scrolled` handler that the anchor's own
correction raised. It isn't a scroll: the view stays where it is, and a
scroll under way, such as an animated `ScrollTo`, carries on. An
animated `ScrollToStart` or `ScrollToEnd` to the edge the view followed
still goes all the way there, as it does without the mode.
- **`ItemsUpdatingScrollMode`:** While the view follows an edge,
`ItemsUpdatingScrollMode` doesn't scroll it. Otherwise that mode applies
as usual, and this PR doesn't change any mode. On `main`,
`KeepItemsInView`, the default, now scrolls the view to its first item
as items are added (#39491, #39493), also a view the user scrolled away
from an edge; `KeepScrollOffset` leaves it where the user scrolled. The
`AnchorMode` remarks say so.

#### How it works

- An internal, platform-agnostic `ScrollAnchorTracker` makes every
decision, following one edge at a time. Its inputs are the offset,
content extent and viewport that the platform reports after each layout
and scroll. Measuring the content extent, rather than tracking items, is
what makes groups, headers, footers and growing items work. The unit
tests spell out its rules.
- The platform code only reads native metrics and scrolls. It uses the
handlers' own signals, with no extra gesture recognizers or external
listeners:
  - **iOS and Mac Catalyst (Items2):**
- Layout: `ItemsViewController2.ViewWillLayoutSubviews` and
`ViewDidLayoutSubviews`. UIKit also lays the view out when the
controller sets a new layout (a header or footer replaced) and when the
items source applies items added, removed or moved. It can move the
offset there before it updates the content size, so the controller
brackets those updates as layout too.
- Scrolling: the `Scrolled`, `DraggingEnded` and `DecelerationEnded`
callbacks on `ItemsViewDelegator2`. A scroll the user isn't making is
judged straight away in `Scrolled`, before the layout pass that measures
the rows it brings into view. It's judged as a new scroll, also right
after a drag, a deceleration or an animated scroll ended, before the
layout pass that looks at where that one stopped. If the content or the
viewport changed size since the anchor last looked, the offset moved for
that change, as when the keyboard manager sets the view's insets, and
it's judged as layout.
- One-shot scrolls: a `ScrollToEnd` without End anchoring finishes in
the layout passes after it, because UIKit estimates rows at 30 points
until it measures them. It finishes only in a layout pass UIKit runs on
its own: one it forces right after the scroll may not have measured the
rows there yet.
- An animated `ScrollToStart` or `ScrollToEnd` to an edge the view
doesn't follow counts as a fling until UIKit reports that its animation
ended, the user drags, or the app requests another scroll, as a
requested smooth scroll does on Android. The anchor used to judge it in
the layout right after the request, before the animation moved the view.
So it followed the edge the view was leaving again, and a row measured,
grown or added before the view got clear of that edge scrolled it back
there, which stopped the animation. UIKit doesn't animate a view that
isn't in a window: it scrolls the view there and reports that the
animation ended before the call returns. The controller counts those
reports, so such a request is done at once, and `ScrollToEnd` goes the
rest of the way as from the end as laid out.
- UIKit keeps the rows in view in place as it measures the rows an
animated scroll to the start brings into view above them, so the
animation stops short of the start by as much as those rows grew. A
one-shot `ScrollToStart` goes the rest of the way once the animation
ends, unless the view stopped further from the start than the content
grew meanwhile, plus 8 units. A scroll stopped the animation then, such
as code moving the native view, and the view stays where that scroll
took it. It used to jump to the start whenever the animation ended.
- A scroll UIKit animates that the anchor didn't start, such as code
animating the native view or a status-bar tap, counts as a fling while
`ScrollAnimating` says it animates (iOS and Mac Catalyst 17+), and the
anchor looks again once UIKit reports its end. It used to be judged as a
scroll the user isn't making: within 8 units of the edge it was leaving,
the view still followed that edge, and a row UIKit measured, or the
content growing, as the animation started took it back there, which
stopped the animation. Before iOS 17 it's judged as before.
- An animated `ScrollTo` counts as a fling the same way while UIKit
animates it. UIKit doesn't animate a scroll to where the item already
is, and never reports an end for it, so the controller checks
`UIScrollView.ScrollAnimating` (iOS and Mac Catalyst 17+) once the
request returns. The anchor used to judge the request in the first
layout, before the animation moved the view: from the end of a list that
follows its end, it kept following the end, and the content changing
then scrolled the view back there, which stopped the animation. Before
iOS 17, which doesn't tell (Mac Catalyst's minimum is 17), it's judged
in the first layout, as before: a content change between that layout and
the animation's first frame still takes the view back to the end there.
- An animated `ScrollToStart` or `ScrollToEnd` to the edge the view
follows keeps following that edge until it gets there. UIKit reports
when its animation ends. An end short of where the animation was going
was a scroll stopping it, such as code moving the native view or a
status-bar tap, unless the anchor's own correction stopped it, UIKit
stopped it while laying the view out, or the content or the viewport
changed size. The anchor then judges where the view stopped. It used to
keep following the edge, so `IsAnchored` stayed `true` and the next
content change pulled the view to the edge. A drag or a newer request
forgets the animation, so the stop that `ScrollToStart` and
`ScrollToEnd` make before they scroll isn't judged.
- An animated `ScrollToStart` or `ScrollToEnd` to the edge the view
follows and is at already doesn't animate, and UIKit reports no end for
it. It now jumps there, as one that doesn't animate does, which judges
where the view is at once. It used to follow the edge as for an
animation on its way there: a scroll away right after it was ignored,
and the rows that scroll brought into view pulled the view back to the
edge.
- A grouped list that measures all its items scrolls to the item again
once an animated `ScrollTo` ends, as on `main`. It now waits for that
end only when UIKit reports one: on iOS and Mac Catalyst 17+ when
`ScrollAnimating` says the scroll animates, and before 17 when the view
is in a window. Otherwise it scrolls again at once. A view that isn't in
a window doesn't animate, and UIKit reports the end before the scroll
returns, so the callback registered after the scroll ran at the end of a
later, unrelated animation, which scrolled back to the item. UIKit never
reports an end for a scroll to where the item already is, either.
- Requests are numbered by the controller. A `ScrollTo`, `ScrollToStart`
or `ScrollToEnd` that a newer request or mode change superseded from its
own `Scrolled` event stops there, also from the layout `ScrollToStart`
and `ScrollToEnd` force before they scroll, and a superseded `ScrollTo`
doesn't arm Mac Catalyst's restore (#34271).
- UIKit records a `scrollToItem` target and applies it again in later
self-sizing layout passes, unless the view really scrolled after
`scrollToItem` returned. So a `ScrollToStart` or `ScrollToEnd` requested
while `ScrollTo` is inside `scrollToItem` runs once it returns.
- Mac Catalyst can move the offset without telling the scroll view
delegate or laying the view out (#34271, #36431). The anchor hears of
that through the `contentOffset` KVO observer `MauiCollectionView`
already has, counts the move as the platform's, and follows its edge
again, replacing the restore of a `ScrollTo` that anchoring clears. The
anchor clears that restore whenever it reports that the view follows an
edge, also when the view got back to it without a drag, as the keyboard
or accessibility scroll it: the restore would otherwise take the view
back to the item when the anchor moves it up as the content shrinks. The
observer tells the controller directly, through a listener it holds
weakly rather than an event, so it doesn't allocate on every scroll
tick.
- While anchored, `LayoutFactory2.FinalizeCollectionViewUpdates` returns
early.
- A mode change stops an animated scroll the app requested, as the view
goes to the edge it now follows. A horizontal layout isn't anchored, so
there a mode change leaves the scroll, the grouped scroll's callback and
Mac Catalyst's restore alone.
- Turning anchoring off while an animated `ScrollToStart` or
`ScrollToEnd` is still on its way to the edge the view followed hands
that scroll to the step that finishes a one-shot scroll once its
animation ends, unless the app requested a newer scroll. Without it, the
scroll stopped where its animation ended, short of an edge that rows
measured on the way had moved.
  - **Android:**
- Signals: `MauiRecyclerView.OnLayout`, `OnScrolled` and
`OnScrollStateChanged`, plus an adapter data observer like the ones
`EmptyView` and `ItemsUpdatingScrollMode` use. RecyclerView keeps the
first row it shows in place as it applies item changes, so the offset
moves even when the content stays the same size. The look after the
layout that applies them counts that move as the layout's. While
anchored, `AdjustScrollForItemUpdate` returns early. The look at a view
whose scroll went idle is posted to the next frame: a scroll reported
before it is judged as a new one, not as the end of the gesture.
- Measuring: RecyclerView's `computeVerticalScrollOffset` and
`computeVerticalScrollRange` are estimates based on the average row
size, so the anchor measures from the laid-out rows instead. The offset
follows a reference row, identified by its view *and* its adapter
position, because RecyclerView reuses a row's view for another row even
within one frame of a fast scroll. Without the first row laid out, the
offset comes from rows laid out before, or from the estimate, which can
be far off with rows of very different heights. A row above the view can
also change size while it isn't laid out: an item replaced, or resized
by a binding, which nothing reports until the row is laid out again. So
the view isn't taken to be at the start until the first row is laid out.
When the first row is laid out again after the offset came from the
estimate, the view moved only as far as the row it kept in view, or the
scroll, says: the anchor tells the tracker that the rest is a new origin
(`ScrollAnchorTracker.MoveOrigin`), not movement. A single scroll away
from the end, by code moving the native view, that first laid out a
first row much taller than the others used to look like a move toward
the end, and the list was pulled back there.
- `ScrollTo` from inside a layout: RecyclerView raises `Scrolled` as it
lays out, and Android drops a layout that a view requests during its own
layout. So a jump requested from there used to land only at some later,
unrelated layout. `ScrollHelper` now requests the layout again once the
current one is over. The adjustment the jump leaves (centering or ending
an item, or reaching the end of a last row taller than the view) waits
for that layout too, instead of running at the end of the current one,
before the jump has scrolled. The anchor judges that request in the
layout that lands it. A correction the anchor has to post the same way,
because the row at the edge isn't laid out yet, leaves the tracker
measuring from where the view was
(`ScrollAnchorTracker.DeferCorrection`), as a scroll can move the view
first: the next look judges that scroll, which stops following the edge
if it took the view away, and otherwise asks for the correction again.
- `ScrollTo(index, groupIndex)` now computes the adapter position from
the group sizes, as the flat index already did. It used to look the item
up one position on (right only for groups with a header) and then search
for an equal item, so it skipped an item, or threw, in groups without a
header, and could land on an equal item in an earlier group. Device
tests call it for a group without a header and for an item equal to one
in an earlier group.
- A `ScrollTo` that doesn't animate, for an index the items don't have
(past the last item, or the header's or footer's position), no longer
replaces a scroll requested before it that hasn't been laid out yet, as
iOS ignores such indices. Animated, it still scrolls there, or to the
last item for an index past it.
- Turning anchoring off while the anchor reports `IsAnchored` stops an
animated scroll to an edge it was about to start. `ScrollToStart` and
`ScrollToEnd` drop a `MandatorySingle` fling's snap target, as
`ScrollTo` does, so the snap doesn't take the view back to it.
- A mode change or a new `ItemsSource` stops an animated scroll the app
requested, all the way to where it ends, as the view goes to the edge it
now follows. RecyclerView's smooth scroller stops once it finds its
target and leaves the rest of the scroll to RecyclerView, which settles
it as it settles a fling, so `IsSmoothScrolling` is `false` for that
last stretch. `MauiRecyclerView` remembers that the scroll is the app's
until the view stops or the user drags it. A fling of the user's still
carries on. On a horizontal layout, which isn't anchored, a mode change
doesn't stop the scroll, and isn't a newer scroll request: a `ScrollTo`
that doesn't animate still jumps to its item when the app changes the
mode from the `RemainingItemsThresholdReached` it raises as it stops a
scroll.
- A new `ItemsLayout` that scrolls vertically after one that didn't
starts the anchor over as `MauiRecyclerView` replaces the layout
manager, as a new view does, rather than at the first look after the
next layout. A `ScrollTo` the app requests right after it, in the same
update, is judged by where it lands, as on iOS and Mac Catalyst, where
the controller looks while it swaps the layout. One requested right
before it was for the layout manager it replaced, and gives way to the
new layout.
- Stopping a scroll raises a pending `RemainingItemsThresholdReached` as
RecyclerView goes idle. A scroll the app requests from it is newer than
the request that stopped the view, so the view doesn't go where that
request was going after it: a mode change, or a `ScrollToStart`,
`ScrollToEnd` or `ScrollTo` that doesn't animate. `ScrollToStart`,
`ScrollToEnd` and a `ScrollTo` that doesn't animate stop the view
themselves before they jump, with or without a matching anchor, because
RecyclerView's `scrollToPosition` would stop it first and then set the
older position.
- An animated `ScrollToStart` or `ScrollToEnd`, with anchoring or
without it, starts once the view is laid out, as iOS lays the view out
before it scrolls. So does one on a horizontal layout, which goes to the
first or last item. RecyclerView's smooth scroller works out how far to
go in the next frame's animation, which comes before that frame's
layout. So a row the app grew with the request moved the end after the
scroll had stopped, and nothing followed it. And a jump to the other
edge that an earlier request left for that layout landed after the
smooth scroller had already stopped, having found its target in place.
The request waits where `ScrollHelper` keeps a jump's adjustment, so a
newer request replaces it. A mode change to `Start` or `End` cancels it,
and the adjustment a jump left, as it stops an animated scroll the app
requested.
- An animated `ScrollTo` whose item is already in place doesn't scroll:
the smooth scroller stops in its first step, and nothing reports that.
The anchor judged the request only at the next content change, after the
change had moved the content, and stopped following the edge the view
was at. It now looks once the smooth scroller has taken its first step,
which judges such a request where the view is, and one that scrolls as a
fling.
- An animated `ScrollTo` for an item starts once the view is laid out
while a jump hasn't been made yet: one from `ScrollToStart`,
`ScrollToEnd` or a `ScrollTo` that doesn't animate, or the anchor's jump
to its edge. RecyclerView makes the jump in the next layout, and the
smooth scroller's first step comes before it: finding the item the view
showed in place, it stopped, and the jump then took the view away.
`ScrollHelper` and the anchor record a jump until that layout. A
`ScrollTo` past the last item, as `KeepLastItemInView` requests, starts
at once as before.
- `ScrollToStart` and `ScrollToEnd` reach the platform through an
internal `IScrollToEdgeHandler`. Where the view can't scroll to an edge
of its content, the handler scrolls to the first or last item it shows,
grouped or not. It finds that item in its own items (the adapter, the
collection view's sections, or WinUI's `CollectionViewSource`), not by
reading `ItemsSource` again, so a sequence that can be read only once
and groups that aren't lists work. Only handlers without the interface
(the obsolete iOS handler, the opt-out Windows `CollectionViewHandler`,
custom handlers) fall back to `ScrollTo` the first or last item
`ItemsSource` gives.

| Platform | `AnchorMode` `Start` and `End` | `ScrollToStart` and
`ScrollToEnd` |
| --- | --- | --- |
| iOS, Mac Catalyst (Items2, the default handler) | vertical layouts |
edges of the content |
| Android | vertical layouts | edges of the content |
| Windows (Items2, the default handler) | not implemented, `IsAnchored`
stays `false` | first and last item (unverified) |
| iOS legacy handler (opt-in) | not implemented | first and last item |
| Horizontal layouts | not anchored | first and last item |

#### Tests

- **Unit tests** (`Controls.Core.UnitTests`): 108/108 pass on .NET 12,
after merging `main` at dfca8ad37c. The whole project passes too: 7033
tests, 30 skipped.
  - 83 tracker tests spell out the rules for both edges.
  - 25 cover the API:
    - `AnchorMode` and `IsAnchored`;
    - how `ScrollToStart` and `ScrollToEnd` reach the handler;
- their `ScrollTo` fallback, grouped lists, and calls without a handler,
which don't read `ItemsSource`.
- **Device tests** (`CollectionViewTests.ScrollAnchor.cs`): 145 cases
run on Android, 142 on iOS and 144 on Mac Catalyst, as some are
platform-specific. They last ran locally on .NET 11, before the merge of
`main` at dfca8ad37c moved the branch to .NET 12; CI runs them on .NET
12. Each review fix was first reproduced without the fix, by a device
test, a unit test, or a scripted check on Mac Catalyst. In the latest
rounds, on the Android emulator unless noted:
- A new test of 2 cases turns a horizontal `End` list vertical and
requests `ScrollTo(10)` right after it, or right before it, in the same
update. Before the change, the case with the request after the switch
failed on Android: item 10 never came into view, as the anchor started
over at its first look after the layout and dropped the request. Both
cases pass on Android and Mac Catalyst.
- Merging `main` (#40577): with #39491 and #39493, `KeepItemsInView`,
the default `ItemsUpdatingScrollMode`, scrolls a list that doesn't
follow an edge to its first item as items are added. 5 tests (9 cases)
check that only the anchor moves such a list, and 8 of those cases
failed with the list at its first item: 7 on Android, and 1 of the 2 Mac
Catalyst cases of another, whose other case passed only because the list
went to its start, away from its end. The 5 tests now set
`KeepScrollOffset`, and pass.
- After the merge, the Mac Catalyst device-test app crashed 3 times in 3
runs (SIGBUS and SIGSEGV in UIKit's observation tracking, during
layout). The first managed failure was an `NSInvalidArgumentException`
("attempt to insert nil object") from `InvalidateItems` in
`ItemsViewController2.InvalidateLayoutIfItemsMeasureChanged`, inside the
layout an animated `ScrollToEnd` forced. The test helpers
`GetItemHeight` and `GetGroupedItemHeight`, called from a `Scrolled`
handler in that layout, disposed the index path they looked up: the
managed peer of UIKit's equal index path, which the handler held for
`InvalidateItems`. They no longer dispose it; the class then passes. The
pre-merge head passed on the same machine (macOS 27.2.1), so the merged
layout timing exposed it.
- On Android, a new test opens an `End` list whose first row is 1000
high and whose other 110 rows are 3 high, so at the end the first row
sits just above the view, measured only by RecyclerView's estimate. Code
then scrolls the native view up 100, which lays that row out. Before the
change, the list was pulled back to its end: the first row at -2455 px
right after the scroll, then row 12 at the top. Two new tracker tests (3
cases) cover `MoveOrigin`; all 3 fail with it doing nothing.
- On Android, a new test of 2 cases (`None`, `Start`) has a
`ScrollTo(5)` that doesn't animate stop an animated scroll on a
horizontal list, and the app changes `AnchorMode` to `End` from the
`RemainingItemsThresholdReached` that stopping raises. Before the
change, both failed: the mode change dropped the jump, and item 5 never
came into view.
- On iOS and Mac Catalyst, a new test of 2 cases calls an animated
`ScrollToStart` or `ScrollToEnd` on a list at that edge, and then has
code scroll the native view 200 away from it. Before the change, both
failed on Mac Catalyst, with the list pulled back to the edge.
- On iOS and Mac Catalyst, a new test of 4 cases (`None` or `End`, the
scroll animated or not) has code scroll the native view to 100 short of
the end right after an animated `ScrollToStart` from the end. Before the
change, both animated cases failed on Mac Catalyst: the jump to the
start overrode that scroll, and the list never got to 100 short of its
end. The others passed before too: UIKit reports the end of an animation
that a scroll without animating stops before it applies that scroll. The
test allows for UIKit moving the end further away as it measures the
rows the scroll brought into view, which once left the list 230 short of
the end, with the offset where the scroll put it.
- That test's animated `End` case also failed in 5 or 6 of 10 repeats,
for a race this round fixes: a row UIKit measured while the view was
still within 8 units of the end took the view back there. A new test
grows the last row as code starts animating the native view of an `End`
list 100 short of the end. Before the change, the list was back at the
end and still anchored in each of 3 tries on Mac Catalyst. Now it ends
where a list without anchoring does: 130 short of the end on macOS 27,
as UIKit measures the rows above again. All 10 repeats of the race pass.
CI's Mac Catalyst run on macOS 26 ended that test 360 short of the end,
where it had checked for at most 300: UIKit there measures the rows
above differently, and iOS 26 and macOS 15 passed it. The anchor only
ever scrolls a list that follows its end to the end, so the test now
checks that the list stays away from both edges (less than half the
scroll range from the end) rather than how far UIKit takes the end.
- The test of a `ScrollToEnd` from `Scrolled` as `ScrollToStart` goes
the rest of the way used to fake UIKit's report that the animation
ended, right after the request, with the list still at the end. It now
lets UIKit stop the animation short of the start: 200 short on Mac
Catalyst, as rows are estimated at 30 and measure 40.
- A new Android test of 4 cases (`ScrollToStart` or `ScrollToEnd`, with
a matching anchor or none) stops an animated scroll past the
`RemainingItemsThresholdReached` threshold with a `ScrollTo(20)` that
doesn't animate, and calls `ScrollToStart` or `ScrollToEnd` from that
event. Before the change, both cases without an anchor failed: the older
`ScrollTo` won, with row 13 at the top, or the end out of view. With a
matching anchor they passed before too, as the anchor's reset takes the
view to its edge.
- On iOS and Mac Catalyst, a new test of 2 cases stops an animated
`ScrollToEnd` on its way with a native scroll back to the start, without
animating, or animated as a status-bar tap does. Before the change, both
failed on the iPhone 18 Pro simulator: the list stayed at its start, but
`IsAnchored` stayed `true`.
- On iOS and Mac Catalyst, a new test of 2 cases (`End`, `MakeVisible`)
makes an animated `ScrollTo` in a grouped list that measures all its
items while the list is out of its window, and then scrolls the native
view back toward the start, animated. Before the change, both failed on
the iPhone 18 Pro simulator: as that animation ended, the list scrolled
back to the item, 1006 from the start (878 when it first showed the
item). UIKit stops that animation short of the start, as it measures the
rows above that the jump skipped, so the test checks that the list
doesn't go back to the item rather than that it reaches the start.
- A new test of 2 cases calls `ScrollToEnd(false)` and then an animated
`ScrollToStart` on a horizontal list at its start, and the reverse.
Before the change, both failed on Android, with the list at the edge it
jumped to. iOS and Mac Catalyst passed before the change too.
- A new test of 4 cases (every `AnchorMode`) calls `ScrollToEnd(false)`
and then an animated `ScrollTo(0)` on a list at its start. Before the
change, all 4 failed on Android with the list at the end (row 32 at the
top), including End and Start | End, where the jump was the anchor's.
iOS and Mac Catalyst passed before the change too.
- On iOS and Mac Catalyst, a new test insets the bottom of an End list
by 300 and scrolls the native view up 200 outside a layout pass, as the
keyboard manager does. The anchor judges that as layout and keeps the
end in view. With the `IsResized` veto removed, it failed on the iPhone
18 Pro simulator: 530 from the end, no longer following it.
- On iOS and Mac Catalyst, a new test has code scroll the native view up
200 right after UIKit reports that an animated scroll ended, before the
layout pass that follows. UIKit reports the end of a drag, a
deceleration or an animated scroll before that pass, and the anchor took
a scroll in between for the end of the one that ended. Before the
change, the list was pulled back to its end on the iPhone 18 Pro
simulator, 0 from the end. A new tracker test covers `IsResized`: an
offset move that comes with a size change is still judged as layout.
- On Mac Catalyst, back at the end of an End list after a `ScrollTo(0)`
that doesn't animate, through native scrolls that aren't drags, a new
test shrinks the last item. Before the change, the restore that
`ScrollTo` armed took the list back to its first item: 30 from the
start, 1100 from the end, not anchored.
- A native scroll up 200 from a scroll listener as a short fling goes
idle, before the anchor's posted look, has a new test. Before the
change, the list was pulled back to its end. Two new tracker tests cover
it: the original code took the view back to the edge, and gating the
gesture-end exemption alone stopped following for a scroll toward the
end.
- Code scrolling the native view up 200 from the GlobalLayout callback
after items are appended, before the anchor's posted jump to the new end
lands, has a new test. Before the change, the list jumped from row 27,
where the scroll left it, to the end at row 52. It passes now, and with
`DeferCorrection` resetting the tracker as before, the 2 new tracker
tests of a scroll away fail.
- An animated `ScrollTo` to the first item, from the end of a list that
follows only its end, has a new test of 2 cases: the last row grows, or
an item is added, once the list is laid out for the request and before
the animation moves it. Before the change, both failed with the list
back at the end: 1040 and 1120 from the start on the iPhone 18 Pro
simulator, 1170 and 1200 on Mac Catalyst. Android needed no change for
them. A new test of an animated `ScrollTo` to where the last item
already is failed on Android before the change: once the last row grew,
the list had stopped following, 80 short of the end. All 3 cases pass on
Android, iOS and Mac Catalyst now.
- CI's Mac Catalyst run on macOS 26 left an animated `ScrollToStart`
from the end of a list that follows only its end at the end, 1220 from
the start, in one of its two runs. A new test of 2 cases grows the last
row, or adds an item, once the list is laid out for the request and
before the animation moves it. Before the change, both failed on the
iPhone 18 Pro simulator and on Mac Catalyst, with the list back at the
end: 1220 from the start for the grown row on Mac Catalyst, as in CI.
Both pass on Android, iOS and Mac Catalyst now. Android needed no
change.
- A throwaway probe on the iPhone 18 Pro simulator showed that UIKit
reports the end of a scroll animation in every case it tried: one that
finishes, one a scroll stops, the view leaving its window, an inset,
content size or visibility change. A view that isn't in a window doesn't
animate: UIKit scrolls it and reports the end before the call returns. A
new iOS and Mac Catalyst test of 2 cases takes the list out of its
window for an animated `ScrollToStart` or `ScrollToEnd`. Before the
change, the `ScrollToStart` case failed on the iPhone 18 Pro simulator:
back at its end, the list didn't follow a new item, 40 short of the end.
Both pass on iOS and Mac Catalyst now.
- An animated `ScrollToStart` or `ScrollToEnd` right after one to the
other edge that doesn't animate, on a list settled at the edge the
animated one goes to, has a new test of 16 cases: every `AnchorMode`,
both edges, and with or without a header and footer. Before the change,
6 failed. The animated `ScrollToStart` that the view doesn't follow
(`AnchorMode` `None` or `End`) left the list at the end. With rows of
one height and no header or footer, an anchored `ScrollToStart` or
`ScrollToEnd` left it at the other edge too. All 16 pass on Android, iOS
and Mac Catalyst now.
- With the data-item check removed, a `ScrollTo` that doesn't animate,
for the footer's index (`items.Count`) or the header's (-1), right after
`ScrollToEnd(false)` cancelled the adjustment that finishes it: the list
stopped 299.8 and 350.1 short of the end.
- iPhone 18 Pro simulator: without the handover, turning `AnchorMode`
off during an animated `ScrollToEnd` or `ScrollToStart` to the edge the
list followed left it 230 short of the end and 130 from the start.
Android reached the edge either way.
- The check that scrolling the native view away as an item is added
stops following the end now runs on iOS and Mac Catalyst too. It passes
there unchanged: UIKit resizes the content as the item is inserted,
which the anchor looks at before the scroll.
- With the request check across the stop removed, a `ScrollTo` requested
from the `RemainingItemsThresholdReached` that stopping a scroll raises
lost to the edge the list went to: for a mode change, and for
`ScrollToEnd` and `ScrollToStart` that don't animate. Without stopping
the view before the jump, all four `ScrollToEnd` and `ScrollToStart`
cases failed, with a matching anchor and without one.
- With the horizontal check removed, both cases of the new test of a
mode change during an animated `ScrollTo` on a horizontal list failed.
On Android the scroll stopped and never reached the item. On the iPhone
18 Pro simulator it stopped too, and UIKit then put the view at the item
in a single jump at the next layout, so the test also checks that the
scroll keeps animating.
- Without the change to the animated `ScrollToEnd`, both cases of its
new test failed, with the last row grown before the request or after it:
the footer stayed out of view.
- CI's Mac Catalyst run on macOS 26 ended the case that grows the row
after the request 50 short of the end, in one of its two runs. iOS and
Mac Catalyst lay the view out as `ScrollToEnd` is called, and follow a
row grown after it only while UIKit measures the rows the scroll brought
into view (see open question 11), so that case runs on Android only.
Both cases check that the view reached the end of the grown row, as the
test of a row measured in a later layout does.
- With `main`'s lookup for `ScrollTo(index, groupIndex)` restored, both
of the new direct calls failed: one threw `ArgumentOutOfRangeException`
for a group without a header, and the other scrolled to the equal item
of the first group.
- With the anchor's stop left as it was, the case of a mode change right
after an animated `ScrollToEnd` failed: the scroll waiting for the
layout still took the list to the end.
- Android API 37 emulator, after merging `main` at bca4740888 (.NET 11):
all 300 `CollectionViewTests` pass, with 1 skip that predates this PR.
- Mac Catalyst (macOS 27.2.1), after merging `main` at bca4740888 (.NET
11): all 209 `CollectionViewTests` pass, with 4 skips that predate this
PR. The latest local iOS run (iOS 27.2) is of an earlier head: all 170
passed. CI's iOS stages, on macOS 15 and macOS 26 hosts, passed every
anchor test on 42c1a3060d. Each has 4 skips that predate this PR. The
Xcode 27.2 SDK requires a scene manifest in the device-test app
(MT7199), so these ran with one added locally. It isn't part of this PR.
- The horizontal cases wait until the list is laid out before they
scroll: before that, a list is at both of its edges, and they passed on
iOS without scrolling.
- CI's device tests on iOS 26 and macOS 26 found failures that iOS 27
and macOS 27 don't show. This head addresses them:
- UIKit moved the offset before it updated the content size, while it
updated the view for a new layout (a replaced header or footer) or for
removed items. The controller now brackets those updates as layout.
- Rows measured during an animated `ScrollToStart` moved the offset away
from the start before any size change was reported. An animated scroll
to an edge now follows that edge until it gets there.
- A one-shot `ScrollToEnd` that doesn't animate finished in the layout
passes it forced, before UIKit measured the rows there. It now finishes
only in a layout pass UIKit runs on its own.

The replaced header and the one-shot `ScrollToEnd` failed locally too,
and pass now. New unit tests cover following an edge on the way there,
and a new device test covers the one-shot `ScrollToEnd`. Only CI can
confirm the fixes on iOS 26 and macOS 26.
- **UI tests** (`CollectionViewAnchorModeEnd`, 3 tests). They cover
following added and growing items, scrolling away and back, and
`ScrollTo` away from the end followed by `ScrollToEnd`. The growing-item
test waits until the last message has grown before it checks that the
footer is in view. Their waits find a row again when the list recycled
it between finding it and reading its geometry.
  - 3/3 on an iPhone 18 Pro simulator (iOS 27.2) with real touch.
  - 3/3 on an Android API 37 emulator.
- **Mac Catalyst and the iPhone 18 Pro simulator:** local scripted
checks of the scenarios above all pass. They include:
  - 32/32 repeated one-shot `ScrollToEnd` runs on each;
- a `ScrollTo` from `Scrolled` or from `IsAnchored` during
`ScrollToEnd`, or from `Scrolled` as `ItemsSource` is replaced;
- a mode change during an animated `ScrollTo`, including before its
first frame;
  - `KeepLastItemInView` with `Start`;
- the restore armed by a `ScrollTo` that doesn't animate. With the two
clears removed, the list goes back to that item.
- **Not run locally:**
- Catalyst UI tests: on this machine Appium loses the app at launch for
any test page, including existing ones.
  - iOS 26 and macOS 26, which only CI has.

<details>
<summary>Commands</summary>

```bash
# Unit tests: 108 passed
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj \
  --filter "FullyQualifiedName~ScrollAnchorTrackerTests|FullyQualifiedName~StructuredItemsViewAnchorModeTests"

# UI tests, with the HostApp installed on the device: 3 passed on each
DEVICE_UDID=<simulator udid> dotnet test src/Controls/tests/TestCases.iOS.Tests/Controls.TestCases.iOS.Tests.csproj \
  --filter "FullyQualifiedName~CollectionViewAnchorModeEnd"
DEVICE_UDID=emulator-5554 dotnet test src/Controls/tests/TestCases.Android.Tests/Controls.TestCases.Android.Tests.csproj \
  --filter "FullyQualifiedName~CollectionViewAnchorModeEnd"

# Android device tests: 300 passed, 1 skipped (on .NET 11, before the merge that moved the branch to .NET 12)
EmbedAssembliesIntoApk=true pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls \
  -Platform android -Configuration Debug -IncludeClasses "Microsoft.Maui.DeviceTests.CollectionViewTests" -BuildOnly
dotnet xharness android test \
  --app artifacts/bin/Controls.DeviceTests/Debug/net12.0-android/com.microsoft.maui.controls.devicetests-Signed.apk \
  --package-name com.microsoft.maui.controls.devicetests \
  --instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation \
  --device-id emulator-5554 -o artifacts/log/anchor-android --timeout 00:45:00

# iOS device tests (with a local scene manifest): 170 passed, 4 skipped, on an earlier head. Mac Catalyst: 209 passed,
# 4 skipped. Both ran on .NET 11. For Mac Catalyst, use -f net12.0-maccatalyst -r maccatalyst-arm64 and --target maccatalyst.
dotnet build src/Controls/tests/DeviceTests/Controls.DeviceTests.csproj -c Debug -f net12.0-ios -r iossimulator-arm64
dotnet xharness apple test \
  --app artifacts/bin/Controls.DeviceTests/Debug/net12.0-ios/iossimulator-arm64/Microsoft.Maui.Controls.DeviceTests.app \
  --target ios-simulator-64_27.2 --device <simulator udid> -o artifacts/log/anchor-ios --timeout 00:40:00 \
  --set-env=NUNIT_SKIPPED_CLASSES=Microsoft.Maui.DeviceTests.CollectionViewTests
```

</details>

#### Open questions for API review

1. **Names.** `ScrollAnchorMode` or `ItemsAnchorMode`? I chose
`ScrollAnchorMode` so a vertical `ScrollView` can reuse it later; the
same tracker already works for one. `AnchorMode` matches Blazor, but it
sits next to `VisualElement.AnchorX` and `AnchorY`, which are transform
anchors.
2. **Default.** It's `None`, so existing apps don't change. Blazor's
default is `Start`.
3. **`IsAnchored`** is a `bool` for either edge. Should it say which
edge the view follows, for `Start | End`?
4. **Changing `AnchorMode`** shows the edge it selects. Blazor doesn't
scroll when the mode changes.
5. **Threshold.** The 8-unit threshold is fixed and internal; Blazor
uses 2 px.
6. **Windows:** `AnchorMode` isn't implemented, because it can't be
verified on a Mac. WinUI's `VerticalAnchorRatio` may fit.
`ScrollToStart` and `ScrollToEnd` scroll to the first and last item the
default handler shows, but that's unverified too: the WinUI XAML
compiler doesn't run on macOS, so it hasn't even been compiled here.
7. **Horizontal layouts and right-to-left** aren't anchored.
8. **Snap points.** With mandatory snap points, `ScrollToEnd` ends at
the nearest snap point, as `ScrollTo` does. On Android, `ScrollToStart`
and `ScrollToEnd` drop the item a `MandatorySingle` fling snapped to, as
`ScrollTo` does, so the snap doesn't take the view back to it. Anchoring
isn't designed for snapping lists.
9. **Mac Catalyst's silent offset clamp (#34271).** It doesn't reproduce
on this machine, through a Picker, minimizing and restoring, or a
resize. The anchor still hears of an offset change only KVO reports, and
follows its edge again: a device test simulates one by moving the
layer's bounds with manual KVO notifications.
10. **Overlap with `ItemsUpdatingScrollMode`** (#39491 and #39493, now
in `main`). While the view follows an edge, the anchor keeps it there:
`AdjustScrollForItemUpdate` on Android and
`FinalizeCollectionViewUpdates` on iOS and Mac Catalyst return early.
Otherwise `ItemsUpdatingScrollMode` applies as before. Its default,
`KeepItemsInView`, scrolls the list to its first item as items are
added, so an `End` list the user scrolled away from jumps to its first
item unless the app sets `KeepScrollOffset`. Should `AnchorMode` keep
the offset while the view doesn't follow an edge?
11. **One-shot `ScrollToEnd` without End anchoring** scrolls once. On
Mac Catalyst with accessibility active, UIKit measures rows above the
view 100 to 300 ms after a scroll without keeping the content in place,
which can leave the view 80 to 100 short of the end. After a row
resizes, UIKit also lays offscreen rows and the header out at their
estimated size and measures them again later, which can leave it 30
short. Both are Items2 behavior that predates this PR, and the device
tests allow for them. Should a one-shot `ScrollToEnd` hold the end until
something else scrolls the view, as UIKit holds a `scrollToItem` target?
Or should Items2 keep the content in view in place as UIKit measures
rows above it, for every scroll?
12. **Turning anchoring off** doesn't stop a scroll under way; a review
suggested it should. It isn't a scroll, and stopping one would make
`ScrollTo(item, animate: true); AnchorMode = None;` drop the scroll
while the reverse order keeps it. An animated `ScrollToStart` or
`ScrollToEnd` to the edge the view followed still goes all the way
there. A change to `Start` or `End` does stop it, as it scrolls to that
edge, except on a horizontal layout, which isn't anchored.

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

N/A: this is a new feature, and it doesn't fully fix any open issue.
Related:

- #35802 (KeepLastItemInView does nothing on .NET 10 iOS and Android):
not fixed here. `AnchorMode="End"` is the alternative for chats.
- #12036, #29153 (grouped lists): `AnchorMode="End"` follows grouped
lists. This PR doesn't change `KeepLastItemInView`; `main` has since
fixed #29153 (#39491, #39493).
- #29420 (CarouselView): out of scope, because CarouselView isn't a
`StructuredItemsView`.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.