diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs index 18ad2776ac..7716e32e26 100644 --- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs @@ -876,7 +876,7 @@ namespace Avalonia.Controls.Primitives private void OnItemsViewSourceChanged(object? sender, EventArgs e) { - if (_selection is not null) + if (_selection is not null && _updateState is null) _selection.Source = ItemsView.Source; } diff --git a/src/Avalonia.Controls/Selection/InternalSelectionModel.cs b/src/Avalonia.Controls/Selection/InternalSelectionModel.cs index 675b92b4ed..d0e6144f59 100644 --- a/src/Avalonia.Controls/Selection/InternalSelectionModel.cs +++ b/src/Avalonia.Controls/Selection/InternalSelectionModel.cs @@ -21,8 +21,6 @@ namespace Avalonia.Controls.Selection SourceReset += OnSourceReset; } - public bool DataContextIsUpdating { get; set; } - [AllowNull] public IList WritableSelectedItems { diff --git a/src/Avalonia.Controls/VirtualizingPanel.cs b/src/Avalonia.Controls/VirtualizingPanel.cs index ee9737132f..a95d4f1ffa 100644 --- a/src/Avalonia.Controls/VirtualizingPanel.cs +++ b/src/Avalonia.Controls/VirtualizingPanel.cs @@ -193,13 +193,13 @@ namespace Avalonia.Controls throw new InvalidOperationException("The VirtualizingPanel is already attached to an ItemsControl"); ItemsControl = itemsControl; - ItemsControl.ItemsView.CollectionChanged += OnItemsControlItemsChanged; + ItemsControl.ItemsView.PostCollectionChanged += OnItemsControlItemsChanged; } internal void Detach() { var itemsControl = EnsureItemsControl(); - itemsControl.ItemsView.CollectionChanged -= OnItemsControlItemsChanged; + itemsControl.ItemsView.PostCollectionChanged -= OnItemsControlItemsChanged; ItemsControl = null; Children.Clear(); }