diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
index 1dcbeaf23e..2eb8d62af8 100644
--- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
+++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
@@ -5,6 +5,7 @@ using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
+using System.Net.Http.Headers;
using Avalonia.Collections;
using Avalonia.Controls.Generators;
using Avalonia.Controls.Utils;
@@ -503,32 +504,58 @@ namespace Avalonia.Controls.Primitives
/// Selects all items in the control.
///
protected void SelectAll()
+ {
+ _selection.Clear();
+
+ for (var i = 0; i < ItemCount; ++i)
+ {
+ _selection.Add(i);
+ }
+
+ UpdateSelectedItem(0, false);
+
+ SyncSelection();
+ }
+
+ ///
+ /// Deselects all items in the control.
+ ///
+ protected void UnselectAll() => UpdateSelectedItem(-1);
+
+ private void SyncSelection()
{
UpdateSelectedItems(() =>
{
- _selection.Clear();
+ var selection = _selection.Select(x => ElementAt(Items, x)).ToList();
+ var added = selection.Except(SelectedItems.Cast