From b42126b9e35cc5ce404963584fee95bc7f1b77c3 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Wed, 18 Sep 2019 19:22:23 +0200 Subject: [PATCH] Properly reset SelectedIndex after the DataContext changed --- src/Avalonia.Controls/Primitives/SelectingItemsControl.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs index 761a3f3b3d..a50175bdee 100644 --- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs @@ -1082,7 +1082,11 @@ namespace Avalonia.Controls.Primitives } else { - if (ItemCount > 0) + if (ItemCount == 0 && SelectedIndex != -1) + { + SelectedIndex = -1; + } + else { SelectedIndex = _updateSelectedIndex != int.MinValue ? _updateSelectedIndex : 0; }