Quellcode durchsuchen

sync selected index with items count when removing items from carousel.

Dan Walmsley vor 7 Jahren
Ursprung
Commit
67d6082730
1 geänderte Dateien mit 2 neuen und 2 gelöschten Zeilen
  1. 2 2
      src/Avalonia.Controls/Presenters/CarouselPresenter.cs

+ 2 - 2
src/Avalonia.Controls/Presenters/CarouselPresenter.cs

@@ -115,9 +115,9 @@ namespace Avalonia.Controls.Presenters
                         var containers = generator.RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                         var containers = generator.RemoveRange(e.OldStartingIndex, e.OldItems.Count);
                         Panel.Children.RemoveAll(containers.Select(x => x.ContainerControl));
                         Panel.Children.RemoveAll(containers.Select(x => x.ContainerControl));
 
 
-                        if(SelectedIndex > containers.Count())
+                        if(SelectedIndex >= Items.Count())
                         {
                         {
-                            SelectedIndex = containers.Count();
+                            SelectedIndex = Items.Count() - 1;
                         }
                         }
 
 
 #pragma warning disable 4014
 #pragma warning disable 4014