From ae4356ef343aa3ebfaae8460296f3b1e412b5b41 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 19 Jul 2018 12:52:45 +0100 Subject: [PATCH] add fix for selecting items control. --- src/Avalonia.Controls/Primitives/SelectingItemsControl.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs index a7b8981583..354c740871 100644 --- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs @@ -355,6 +355,12 @@ namespace Avalonia.Controls.Primitives case NotifyCollectionChangedAction.Replace: var selectedIndex = SelectedIndex; + var items = Items?.Cast(); + if (selectedIndex >= items.Count()) + { + selectedIndex = SelectedIndex = items.Count() - 1; + } + if (selectedIndex >= e.OldStartingIndex && selectedIndex < e.OldStartingIndex + e.OldItems.Count) {