From 57dcfadf57175590313c136ed8bf8d96e0e8ff8d Mon Sep 17 00:00:00 2001 From: MonkAlex <3amepob@gmail.com> Date: Sun, 10 Mar 2019 00:40:48 +0400 Subject: [PATCH] #2355 'Select all' support TreeView too, only visible part of tree. --- src/Avalonia.Controls/TreeView.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Avalonia.Controls/TreeView.cs b/src/Avalonia.Controls/TreeView.cs index db8de49494..141a151bdb 100644 --- a/src/Avalonia.Controls/TreeView.cs +++ b/src/Avalonia.Controls/TreeView.cs @@ -10,6 +10,7 @@ using Avalonia.Collections; using Avalonia.Controls.Generators; using Avalonia.Controls.Primitives; using Avalonia.Input; +using Avalonia.Input.Platform; using Avalonia.Interactivity; using Avalonia.Threading; using Avalonia.VisualTree; @@ -402,6 +403,19 @@ namespace Avalonia.Controls SelectedItem = ElementAt(Items, 0); } } + + if (!e.Handled) + { + var keymap = AvaloniaLocator.Current.GetService(); + bool Match(List gestures) => gestures.Any(g => g.Matches(e)); + + if (this.SelectionMode == SelectionMode.Multiple && Match(keymap.SelectAll)) + { + var allVisibleItems = ItemContainerGenerator.Index.Items.Select(ItemContainerGenerator.Index.ItemFromContainer); + SelectingItemsControl.SynchronizeItems(SelectedItems, allVisibleItems); + e.Handled = true; + } + } } private TreeViewItem GetContainerInDirection(