Browse Source
When a collection bound to a SelectingItemsControl (e.g. ListBox) was cleared via NotifyCollectionChangedAction.Reset, the SelectionChanged event was not raised despite the selection being lost. The root cause was in InternalSelectionModel.OnSourceReset: the base SelectionModel.OnSourceReset() directly reset _selectedIndex to -1 before any Operation could capture the old selection state. The subsequent SyncFromSelectedItems created an Operation that saw no change (old and new both -1), so CommitOperation never fired SelectionChanged. The fix snapshots _writableSelectedItems before sync, diffs against the post-sync state to find items that were actually lost (not merely re-selected at a new index after reorder), and injects them as DeselectedItems on the pending Operation — following the same pattern used by OnSelectionRemoved for individual item removals. Fixes #20897pull/20942/head
2 changed files with 141 additions and 1 deletions
Loading…
Reference in new issue