From 397d972db8b43ad6c50b1889bdb59d20e54c3085 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Wed, 24 Jul 2019 23:36:28 +0200 Subject: [PATCH] Auto-select first item on `Reset`. When a reset is received by `SelectingItemsControl` which has `AlwaysSelect == true`, select the first item if present. Fixes #2754 --- src/Avalonia.Controls/Primitives/SelectingItemsControl.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs index 188685f796..c8c15bc079 100644 --- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs @@ -333,6 +333,11 @@ namespace Avalonia.Controls.Primitives case NotifyCollectionChangedAction.Move: case NotifyCollectionChangedAction.Reset: SelectedIndex = IndexOf(Items, SelectedItem); + + if (AlwaysSelected && SelectedIndex == -1 && ItemCount > 0) + { + SelectedIndex = 0; + } break; } }