diff --git a/src/Avalonia.Controls/Generators/TreeContainerIndex.cs b/src/Avalonia.Controls/Generators/TreeContainerIndex.cs index 24b3fc1f32..0a65dd9ff1 100644 --- a/src/Avalonia.Controls/Generators/TreeContainerIndex.cs +++ b/src/Avalonia.Controls/Generators/TreeContainerIndex.cs @@ -36,6 +36,11 @@ namespace Avalonia.Controls.Generators /// public IEnumerable Items => _containerToItem.Keys; + /// + /// Gets the items of currently materialized containers. + /// + public IEnumerable Objects => _containerToItem.Values; + /// /// Adds an entry to the index. /// diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index 141a151bdb..abd9bc4232 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -411,8 +411,7 @@ namespace Avalonia.Controls if (this.SelectionMode == SelectionMode.Multiple && Match(keymap.SelectAll)) { - var allVisibleItems = ItemContainerGenerator.Index.Items.Select(ItemContainerGenerator.Index.ItemFromContainer); - SelectingItemsControl.SynchronizeItems(SelectedItems, allVisibleItems); + SelectingItemsControl.SynchronizeItems(SelectedItems, ItemContainerGenerator.Index.Objects); e.Handled = true; } }