Skip to content

fix(itemcollection): Raise VectorChanged when an item is replaced - #26348

Draft
Xiaoy312 wants to merge 1 commit into
masterfrom
dev/xygu/20261112/itemcollection-indexer-replace
Draft

Xiaoy312 wants to merge 1 commit into
masterfrom
dev/xygu/20261112/itemcollection-indexer-replace

Conversation

@Xiaoy312

@Xiaoy312 Xiaoy312 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: none (found while porting ListBox, #26321)

PR Type:

🐞 Bugfix

What changed? 🚀

ItemCollection's indexer setter (Items[i] = x) replaced the item without raising VectorChanged. No ItemsControl saw the replacement: the container kept showing the old item, and ContainerFromItem still found it.

The setter now raises ItemChanged. Like a replacement in an ItemsSource, the event carries the old and new items, so the ItemsControl's collection-change handling knows what was replaced.

Validation

  • New runtime test Given_ItemsControl.When_Items_Indexer_Set_Then_Container_Updated, for a plain ItemsControl and a ListView: it fails without the fix and passes with it on Skia desktop. It also passes on native WinUI.
  • Skia desktop: Given_ItemsControl, Given_ListViewBase, Given_ListViewBase_Items, Given_ComboBox, Given_FlipView, Given_Selector: 238 passed, 0 failed, 16 skipped, 1 inconclusive (When_Large_List_Scroll_To_End_Then_Back_Up_TryClick, also inconclusive without this change).
  • Skia desktop, the other item consumers: Given_Pivot, Given_TabView, Given_GridView_Items, Given_AutoSuggestBox, Given_ListBox, Given_ItemsStackPanel: 42 passed, 0 failed, 3 skipped. The Items.VectorChanged subscribers and OnItemsChanged overrides (AutoSuggestBox, ComboBox, FlipView, TabViewListView, Pivot's presenter, Selector) already get ItemChanged from a replacement in an ItemsSource; none of them throws on it.

PR Checklist ✅

🤖 Generated with Claude Code

ItemCollection's indexer setter (Items[i] = x) replaced the item without
raising VectorChanged, so the ItemsControl kept showing the old item in
its container. It now raises ItemChanged, carrying the old and new items
like a replacement in an ItemsSource.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 245690 found UI Test snapshots differences: skia-linux-screenshots: 211, skia-windows-screenshots: 310

Details
  • skia-linux-screenshots: 211 changed over 2496

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • AnimatedVisualsTestbedPage.png-dark
    • Basics.png-dark
    • Basics.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • CompositionPath.png-dark
    • CompositionPath.png
    • AnimatedVisualsTestbedPage.png
    • AutomationProperties_AutomationId.png-dark
    • BasicAcrylicBrushTest2.png-dark
  • skia-windows-screenshots: 310 changed over 2496

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedBackVisualSourceSamplePage.png
    • AppWindowTitleBar Properties.png-dark
    • Buttons.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • AnimatedBackVisualSourceSamplePage.png-dark
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • AppWindowTitleBar Properties.png
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ComboBox_MaxDropdownHeight.png-dark
    • ComboBox_MaxDropdownHeight.png
    • AnimatedVisualsTestbedPage.png-dark
    • Basics.png-dark
    • Basics.png

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.

3 participants