Repository navigation
Open
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewcollectionview-winui-cv2platform/windowss/triagedIssue has been reviewed
Description
Tracking issue for non-blocking follow-ups identified during review of #34600 (WinUI CollectionView2 handler, now merged). None of these blocked the merge — each is an edge case or pre-existing parity item suitable for an independent follow-up PR. Surfaced by multi-model adversarial review across rounds 1–4 on #34600.
Null source-item handling
When a data source contains null elements, three CV2 Windows consumers mishandle the now-reachable null (the null-skip guard was intentionally removed in ObservableItemTemplateCollection2 to fix index desync, so null items now flow through):
-
ItemFactory.cs:124— null item renders in the Selected visual state. WithSelectionMode=Singleand nothing selected,object.Equals(SelectedItem=null, Item=null)returnstrue, so anullrow paints as selected. Fix: guardtemplateContext.Item is not nullbefore the equality check. -
MauiItemsView.DragDrop.cs:1266— stale drag index on null cells.UpdateAllContainerIndicesskips null-item containers, so theirTaggoes stale after a reorder and dragging the blank cell can move the wrong row. Fix: clear theTagwhen the item is null (or resolve the index viaGetElementIndex). -
GroupedItemTemplateCollection2.cs:324— groupedReplacewith a null value desyncs.HandleGroupItemsReplacestill hasif (item is null) continue;, leaving the old context in place and emitting a malformedReplace. Fix: mirror the null-parity handling used in the flat collection.
Source / layout semantics
-
ItemsViewHandler2.Windows.cs:362— non-grouped collection-of-collections is flattened. WhenIsGrouped=falsebutItemsSourceitems are themselves non-stringIEnumerable, theIsItemsSourceGroupedheuristic (L360) flattens the source. CV1 instead binds each inner collection as a single item. Also reachable if a model type happens to implementIEnumerable. Non-crashing behavior difference vs CV1. Fix: gate theelse-branch flatten onIsGrouped.
INCC robustness (pre-existing CV1 parity — low priority)
-
ObservableItemTemplateCollection2.cs:420/:239,247— indexlessReplace/Movecan throw. A customINotifyCollectionChangedsource raisingReplace/Movewith a-1starting index computesOldStartingIndex + index→this[-1]→ArgumentOutOfRangeException. Not a regression — the current CV1ObservableItemTemplateCollection(Platform/Windows/CollectionView) is line-for-line identical, andRemovein both already guards< 0with aReset(). Rare trigger (ObservableCollection<T>always supplies indices); the grouped sibling already bounds-guards viaResetWithoutResubscribe(). Fix (ideally cross-platform): mirror theRemove< 0 → Reset()guard inReplace/Move.
CI / pipeline
-
eng/pipelines/common/ui-tests-build-sample.yml— duplicateui-tests-samples-windows_failedartifact name. Two failure-publish steps collide whenplatform=windows && useWindowsCV1=false && failed(): one condition is(windows, cv1=false, failed)and another is(windows, failed), both publishingui-tests-samples-windows_failed_$(System.JobAttempt). The second publish errors on the duplicate artifact name. Fix: make the conditions mutually exclusive (or give the CV1/default lanes distinct artifact names).
Needs verification (cleanup code was added since these were flagged — may already be mitigated)
-
ItemFactory.cs:233— confirmRecycleElementclearsBindingContext/DataContexton pooled containers (stale-binding risk). -
ItemFactory.cs:420— confirmMeasureFirstItemsize cache can't be polluted by a recycled first item.
Already addressed (no action needed)
ObservableItemTemplateCollection2.cs_innerCollectionChangeis now correctly wrapped intry/finally. ✓
Reacted by github-actions
Metadata
Metadata
Assignees
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewcollectionview-winui-cv2platform/windowss/triagedIssue has been reviewed
Activity
Fix null-item bugs in CollectionView2 Windows handler (Issue #36068)
Fix null-item selection highlight in CV2 Windows (Issue #36068)