From 889156df434cd59eccf267101ea470e68e62ab4e Mon Sep 17 00:00:00 2001 From: Andrey Kunchev Date: Tue, 16 Oct 2018 01:09:43 +0300 Subject: [PATCH] fixes #1971 listbox toggle selection --- .../Primitives/SelectingItemsControl.cs | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs index f8440aac47..ccbdc71b1d 100644 --- a/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs +++ b/src/Avalonia.Controls/Primitives/SelectingItemsControl.cs @@ -62,7 +62,7 @@ namespace Avalonia.Controls.Primitives AvaloniaProperty.RegisterDirect( nameof(SelectedItem), o => o.SelectedItem, - (o, v) => o.SelectedItem = v, + (o, v) => o.SelectedItem = v, defaultBindingMode: BindingMode.TwoWay); /// @@ -88,7 +88,7 @@ namespace Avalonia.Controls.Primitives /// public static readonly RoutedEvent IsSelectedChangedEvent = RoutedEvent.Register( - "IsSelectedChanged", + "IsSelectedChanged", RoutingStrategies.Bubble); /// @@ -96,7 +96,7 @@ namespace Avalonia.Controls.Primitives /// public static readonly RoutedEvent SelectionChangedEvent = RoutedEvent.Register( - "SelectionChanged", + "SelectionChanged", RoutingStrategies.Bubble); private static readonly IList Empty = new object[0]; @@ -521,7 +521,7 @@ namespace Avalonia.Controls.Primitives else if (multi && range) { SynchronizeItems( - SelectedItems, + SelectedItems, GetRange(Items, SelectedIndex, index)); } else @@ -583,7 +583,7 @@ namespace Avalonia.Controls.Primitives } /// - /// Updates the selection based on an event that may have originated in a container that + /// Updates the selection based on an event that may have originated in a container that /// belongs to the control. /// /// The control that raised the event. @@ -595,7 +595,7 @@ namespace Avalonia.Controls.Primitives /// false. /// protected bool UpdateSelectionFromEventSource( - IInteractive eventSource, + IInteractive eventSource, bool select = true, bool rangeModifier = false, bool toggleModifier = false) @@ -807,12 +807,10 @@ namespace Avalonia.Controls.Primitives SelectedIndex = -1; } } - else + + foreach (var item in e.OldItems) { - foreach (var item in e.OldItems) - { - MarkItemSelected(item, false); - } + MarkItemSelected(item, false); } removed = e.OldItems;