1
0
Эх сурвалжийг харах

#2355 Ctrl+A hotkey for SelectingItemsControl

MonkAlex 6 жил өмнө
parent
commit
e3d7d47753

+ 17 - 0
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

@@ -459,6 +459,23 @@ namespace Avalonia.Controls.Primitives
             }
         }
 
+        /// <summary>
+        /// Handles 'select all' (Ctrl+A) in <see cref="SelectingItemsControl"/>.
+        /// </summary>
+        /// <param name="e">The key events.</param>
+        protected override void OnKeyDown(KeyEventArgs e)
+        {
+            base.OnKeyDown(e);
+
+            if (!e.Handled)
+            {
+                if (this.SelectionMode == SelectionMode.Multiple && e.Key == Key.A && e.Modifiers == InputModifiers.Control)
+                {
+                    SynchronizeItems(SelectedItems, Items?.Cast<object>());
+                }
+            }
+        }
+
         /// <summary>
         /// Moves the selection in the specified direction relative to the current selection.
         /// </summary>