瀏覽代碼

#2355 Direct access for treeview index values when select all.

MonkAlex 6 年之前
父節點
當前提交
33a6ae8215
共有 2 個文件被更改,包括 6 次插入2 次删除
  1. 5 0
      src/Avalonia.Controls/Generators/TreeContainerIndex.cs
  2. 1 2
      src/Avalonia.Controls/TreeView.cs

+ 5 - 0
src/Avalonia.Controls/Generators/TreeContainerIndex.cs

@@ -36,6 +36,11 @@ namespace Avalonia.Controls.Generators
         /// </summary>
         public IEnumerable<IControl> Items => _containerToItem.Keys;
 
+        /// <summary>
+        /// Gets the items of currently materialized containers.
+        /// </summary>
+        public IEnumerable<object> Objects => _containerToItem.Values;
+
         /// <summary>
         /// Adds an entry to the index.
         /// </summary>

+ 1 - 2
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;
                 }
             }