Skip to content

[Windows] Fix grouped CollectionView item display in CollectionViewHandler2 - #40607

Merged
kubaflo merged 5 commits into
dotnet:candidate/11.0.1xx-sr3from
devanathan-vaithiyanathan:fix-40414
Nov 30, 2026
Merged

kubaflo merged 5 commits into
dotnet:candidate/11.0.1xx-sr3from
devanathan-vaithiyanathan:fix-40414

Conversation

@devanathan-vaithiyanathan

@devanathan-vaithiyanathan devanathan-vaithiyanathan commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Target Branch

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

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

Issue Details:

On Windows, a grouped CollectionView using CV2 can appear empty after resetting ItemsSource or navigating back to the page.

Root Cause:

The item handler is disconnected during cleanup, but its wrapper retains the old, empty native view.

Description of Changes:

After disconnecting the handler, remove the old size observer, clear the wrapper’s content and unwire the Unloaded event. This allows the native view to be recreated when needed.

Issues Fixed

Fixes #40414

Tested the behavior in the following platforms.

  • Android
  • Windows
  • iOS
  • Mac
Before After
Windows
Before-40414.mp4
Windows
After-40414.mp4

@github-actions

This comment has been minimized.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 25, 2026
@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 2 findings

Reviewed commit bca604d.

See inline comments for details.

@vishnumenon2684

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@sheiksyedm
sheiksyedm marked this pull request as ready for review November 27, 2026 07:39
@sheiksyedm
sheiksyedm requested a balanced review from Copilot November 27, 2026 07:39

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

The new screenshot assertion lacks required baseline images, so the test will fail even when grouped items render correctly.

1 open issue
What changed in this PR

Fixes grouped CollectionView rendering after source resets or navigation on Windows by allowing CollectionViewHandler2 to recreate disconnected item views.

Changes:

  • Clears stale wrapper content after automatic handler disconnection.
  • Removes size and unload observers during cleanup and protects current observers from late unload events.
  • Adds a grouped CollectionView reproduction page and a navigation regression test.
File Description
src/​Controls/​tests/​TestCases.Shared.Tests/​Tests/​Issues/​Issue40414.cs Adds flyout navigation and screenshot verification.
src/​Controls/​tests/​TestCases.HostApp/​Issues/​Issue40414.cs Adds grouped content that resets its source on appearance.
src/​Controls/​src/​Core/​Handlers/​Items2/​Windows/​ItemFactory.cs Tightens size and unload observer cleanup.
src/​Controls/​src/​Core/​Handlers/​Items2/​ItemsViewHandler2.Windows.cs Clears disconnected native content so wrappers can recreate it.

Review effort: Balanced

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 2 findings

Reviewed commit bca604d.

Previously reported findings were not duplicated.

@kubaflo kubaflo 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.

Could you please check the failed tests?

@github-actions

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 2 findings

Reviewed commit 41848ba.

See inline comments for details.

Previously reported findings were not duplicated.

@kubaflo kubaflo 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.

Ui tests are failing. Please don't comment /azp run maui-pr-uitests, and maui-pr-devicetests. You can do /review run-tests

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it label Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

MAUI Autopilot — Started

Models
  • Review: GPT-6.1 Sol (MAUI expert reviewer)
  • Fix: GPT-6.2 Sol, MAI Code 2 and Claude Opus 5.5 fix independently, then cross-examine each other; the best fix is kept
  • Test selection: GPT-6.2 Sol and MAI Code 2
Info
Label Meaning
s/autopilot-reviewing The MAUI expert reviewer is reviewing the PR
s/autopilot-fixing Fixing review findings or failing tests
s/autopilot-testing Running the relevant UI and device tests
s/autopilot-waiting-for-maintainer-review Review clean and tests passed
s/autopilot-needs-maintainer-decision The loop stopped; a maintainer decides how to continue

@github-actions github-actions Bot added the s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) label Nov 27, 2026
@github-actions github-actions Bot mentioned this pull request Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

MAUI Autopilot · round 1

The fix was committed locally but not published: the follow-up PR exceeded the publishing tool’s patch-size limit. The review threads remain open.

@github-actions github-actions Bot removed s/autopilot-running MAUI Autopilot loop is running; remove this label to stop it s/autopilot-fixing MAUI Autopilot: fixing review findings or failing tests (GPT-6.2 Sol vs MAI Code 2) labels Nov 27, 2026
@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 2 findings

Reviewed commit a978a6e.

See inline comments for details.

App.TapInShellFlyout("Flyout2Content");
App.WaitForElement("GroupedCollectionView");

VerifyScreenshot(retryTimeout: TimeSpan.FromSeconds(2));

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.

[moderate] Regression Prevention and Test Coverage - The added baselines still omit two enabled configurations: snapshots/windows-cv1 and snapshots/ios. The CollectionView shard runs in the Windows CV1 lane with UseWindowsCV1:true and in the iOS 18.4 lane (eng/pipelines/common/ui-tests.yml and eng/pipelines/ui-tests.yml). VerifyScreenshot() selects windows-cv1 and ios respectively, and VisualRegressionTester requires that exact directory without falling back to windows or ios-26. These configurations therefore fail with a missing baseline even when the grouped items render correctly. Add GroupedItemsAreDisplayedAfterNavigatingBackToFlyoutPage.png for both configurations, or replace the screenshot assertion with rendered-content assertions.

_observedContent = null;

// A late unload from replaced content must not clear the current observer.
if (ReferenceEquals(_observedContent, sender))

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.

[moderate] Regression Prevention and Test Coverage - No discriminating test protects this stale-sender guard or the replacement observer's lifecycle. Issue40414 uses MeasureAllItems and static labels, so its screenshot cannot verify that replacement size growth updates the MeasureFirstItem cache. Existing reattachment and source-swap tests also do not deliver an old content element's Unloaded callback after installing a replacement observer. Add a focused Windows test for that ordering, assert that the replacement remains tracked and updates the cache on growth, then recycle it and assert that subsequent growth cannot update the cache. Removing the guard should fail that test; the current navigation test does not distinguish the guarded and unguarded implementations.

@github-actions

Copy link
Copy Markdown
Contributor

Selected Tests

@kubaflo — AI-selected UI tests and device tests (GPT-6.2 Sol + MAI Code 2) for commit a978a6e0.

Result NOT QUEUED Platforms Android, iOS, MacCatalyst, Windows Tests 8 UI, 2 device Commit a978a6e0


🧪 Test selection — click to expand
Suite Result Selected Build
UI tests ❌ not queued 8 of 77 categories —
Device tests ❌ not queued 2 of 105 units —
🧪 UI tests — CarouselView, CollectionView1, CollectionView2, CollectionView3 +4 on Android, iOS, MacCatalyst, Windows

❌ Could not queue maui-pr-uitests: Azure Pipelines did not start maui-pr-uitests for the dispatch branch run-tests/pr40607-46378887659 within 10 minutes. Comment /review run-tests again, or use /azp run maui-pr-uitests for the full suite.

GPT-6.2 Sol: Run CollectionView and CarouselView UI coverage for the Windows Items2 fix and the new cross-platform grouped CollectionView regression.
MAI Code 2: Windows-only CollectionView2 cleanup fix; runs CollectionView UI coverage on Windows.

🧪 Running — 8 categories on Android, iOS, MacCatalyst, Windows

Platform Categories
Android CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7
iOS CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7
MacCatalyst CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7
Windows CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7
🧪 Device tests — Controls.CarouselView, Controls.CollectionView on Windows

❌ Could not queue maui-pr-devicetests: Azure Pipelines did not start maui-pr-devicetests for the dispatch branch run-devicetests/pr40607-46378887659 within 10 minutes. Comment /review run-tests again, or use /azp run maui-pr-devicetests for the full suite.

GPT-6.2 Sol: Run Windows Controls CollectionView and CarouselView device tests for the Items2 cleanup change.
MAI Code 2: Windows Items2 handler cleanup; runs the CollectionView and CarouselView controls device suites on Windows.

🧪 Running — 2 categories on Windows

Platform Categories
Windows Controls.CarouselView, Controls.CollectionView
⏭️ Skipped — what neither suite runs

UI tests — 69 categories, 0 platforms

Categories not run: Accessibility, ActionSheet, ActivityIndicator, Animation, AppLinks, Border, BoxView, Brush, Button, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DisplayPrompt, DragAndDrop, Entry, Editor, Effects, Essentials, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Navigation, Page, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, Shell1, Shell2, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView, Material3

Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.

Device tests — 103 categories, 3 platforms

Platforms not run: Android, iOS, MacCatalyst

Categories not run: Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CheckBox, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay, Graphics, Essentials, BlazorWebView

Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.

🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)

UI tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, CarouselView —
iOS CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, CarouselView —
MacCatalyst CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, CarouselView —
Windows CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, CarouselView CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7

GPT-6.2 Sol — Run CollectionView and CarouselView UI coverage for the Windows Items2 fix and the new cross-platform grouped CollectionView regression.

  • The Windows Items2 handler and item factory change wrapper cleanup; select the Items2 categories.
  • Shared Issue40414 and its four screenshot baselines require all four UI platforms.
  • The Shell flyout is only the test setup; no Shell or full-suite run is needed.

MAI Code 2 — Windows-only CollectionView2 cleanup fix; runs CollectionView UI coverage on Windows.

  • ItemsViewHandler2.Windows.cs and Windows/ItemFactory.cs change only the Windows CollectionView2 item cleanup path.
  • The new shared Issue40414 test is categorized as CollectionView and directly covers grouped-item display after Shell navigation.
  • No other platforms are affected by the production changes; added cross-platform snapshots do not require widening the runtime selection.
  • Shell is intentionally omitted because the fix is in CollectionView item recreation rather than Shell navigation.

Device tests

Each model chose independently; every test that runs was selected by at least one of them.

Platform GPT-6.2 Sol MAI Code 2
Android — —
iOS — —
MacCatalyst — —
Windows Controls.CollectionView, Controls.CarouselView Controls.CollectionView, Controls.CarouselView

GPT-6.2 Sol — Run Windows Controls CollectionView and CarouselView device tests for the Items2 cleanup change.

  • ItemsViewHandler2.Windows.cs and Windows/ItemFactory.cs change item wrapper recycling and observer cleanup; select the two Controls Items2 units.
  • The regression page, test, and snapshots are UI-only; no other device platforms or projects are affected.

MAI Code 2 — Windows Items2 handler cleanup; runs the CollectionView and CarouselView controls device suites on Windows.

  • Windows-specific changes are in the shared Items2 handler code used by CollectionView2, mapping to Controls.CollectionView.
  • Items/Items2 changes also cover CarouselView2 item handling, so Controls.CarouselView is included.
  • Android, iOS, and MacCatalyst are omitted because no production code for those platforms changed.
  • No base layout, app startup, shared device infrastructure, or broad mapper code changed, so a full device run is unnecessary.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

@kubaflo
kubaflo changed the base branch from net11 to candidate/11.0.1xx-sr3 November 30, 2026 11:59
@kubaflo
kubaflo merged commit eacf295 into dotnet:candidate/11.0.1xx-sr3 Nov 30, 2026
3 of 6 checks passed
kubaflo added a commit that referenced this pull request Dec 4, 2026
…apshot baselines (#41221)

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

Self-reported assessment, not an independent review.

Assessed revision: `2e7b2104c43b5a8b8838496ea97c1010a4c90a9e`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 8.5/10 | ↑ Test-only change that adds two baseline
PNGs and touches no product code.<br>↑ Windows image is byte-identical
(MD5) to the CI actual from the windows-cv1 CollectionView1 job
artifact.<br>↑ iOS 18.5 and latest lanes produced pixel-identical
actuals, and the layout matches the existing ios-26 baseline.<br>↓
maui-pr-uitests has not yet run on this head. |
<!-- /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!

### Description of Change

#40607 added
`Issue40414.GroupedItemsAreDisplayedAfterNavigatingBackToFlyoutPage` to
`candidate/11.0.1xx-sr3`. It shipped baselines for `android`, `mac`,
`windows` and `ios-26` only. As a result, the **windows-cv1** and **iOS
18.5 (`ios`)** lanes of maui-pr-uitests fail with a missing baseline.

This PR adds those two baselines from the CI actuals:
-
`TestCases.WinUI.Tests/snapshots/windows-cv1/GroupedItemsAreDisplayedAfterNavigatingBackToFlyoutPage.png`:
all three groups (A–G) render correctly.
-
`TestCases.iOS.Tests/snapshots/ios/GroupedItemsAreDisplayedAfterNavigatingBackToFlyoutPage.png`:
same layout as the committed `ios-26` baseline. The 18.5 and latest
lanes are pixel-identical.

The separate Windows CollectionViewHandler2 (`windows`) failure of this
test is a product issue and is not addressed here.

### Issues Fixed

Fixes missing-baseline failures on candidate/11.0.1xx-sr3
maui-pr-uitests (Controls CollectionView1, windows-cv1 and iOS).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Dec 4, 2026
…emsSource resets while unloaded (#41278)

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

Self-reported assessment, not an independent review.

Assessed revision: `817bc26d9bbbf142fc7b75e41bf579ae265e77b1`

| Dimension | Assessment | Rationale |
|---|---|---|
| Change confidence | 6/10 | ↑ Loaded-view path is byte-identical to
#40962, so its crash/hang protection and device tests (all assert loaded
wrappers) are unchanged.<br>↓ No Windows host was available, so the fix
is not yet validated locally; maui-pr-uitests Windows CV2 and
maui-pr-devicetests on this PR are the evidence that will confirm or
refute it. |
| Diagnosis confidence | 8/10 | ↑ #40607 PR build 1702675 Windows actual
image matches the committed baseline exactly (0 px diff); current sr3
(with #40962) renders the list blank in every test-running build.<br>↑
#40962 sets VirtualView=null, which removes the recreate-on-measure path
#40607 depended on.<br>↓ That the page is unloaded during OnAppearing is
inferred from Shell/WinUI ordering, not traced. |
| Evidence fit | 8/10 | ↑ Failure begins with the first test-running sr3
builds after #40962 merged; the test only exists on sr3. |
<!-- /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!

### Description of Change

`Issue40414.GroupedItemsAreDisplayedAfterNavigatingBackToFlyoutPage`
fails on Windows CV2 in every sr3 maui-pr-uitests build because the
grouped list is blank.

**Root cause.** Two fixes that merged straight into
`candidate/11.0.1xx-sr3` conflict:
- #40607 (fixes #40414) detached the item content but kept
`wrapper.VirtualView`. When WinUI re-measures a wrapper,
`EnsurePlatformViewCreated` rebuilds the view.
- #40962 (fixes #40655) replaced that with `ReleaseContent()`, which
also sets `VirtualView = null`. This was deliberate, so that retired
wrappers cannot recreate content during measurement while the list is
visible.

The repro page is a cached Shell page that resets `ItemsSource` in
`OnAppearing`, while the page is still unloaded. When the page loads
again, WinUI reuses those realized wrappers. Their `VirtualView` is now
null, so nothing renders.

**Evidence.**
- The #40607 PR build
[1702675](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1702675)
produced a Windows image identical to the committed baseline (0 px
diff).
- sr3
[1708237](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1708237)
shows only the "Flyout2Content" title.

**Fix.** `CleanUpCollectionViewSource` now chooses the release mode
based on whether the wrapper is loaded:
- **Loaded wrappers:** call `ReleaseContent()` (unchanged #40962
behaviour).
- **Unloaded wrappers:** call a new `DetachContent()`. It unwires the
size observer and sets `Content = null`, keeping `VirtualView`. Handlers
are still disconnected after the native content is detached, so #40962's
ordering is preserved. The wrapper can then recreate its view when the
page loads again.

**Validation.**
- Not run locally: no Windows host is available.
- This PR relies on maui-pr-uitests (Windows CV2 `Issue40414`) and
maui-pr-devicetests (`CollectionView2MemoryTests.Windows`, whose tests
all use loaded wrappers).

### Issues Fixed

Fixes #40414 regression on candidate/11.0.1xx-sr3 (re-broken by #40962)

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

Labels

area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-winui-cv2 community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows][.NET 11] CollectionViewHandler2 does not display grouped CollectionView items

5 participants