Browse Source

fixes #1971 listbox toggle selection

pull/1973/head
Andrey Kunchev 8 years ago
parent
commit
889156df43
  1. 20
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

20
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

@ -62,7 +62,7 @@ namespace Avalonia.Controls.Primitives
AvaloniaProperty.RegisterDirect<SelectingItemsControl, object>( AvaloniaProperty.RegisterDirect<SelectingItemsControl, object>(
nameof(SelectedItem), nameof(SelectedItem),
o => o.SelectedItem, o => o.SelectedItem,
(o, v) => o.SelectedItem = v, (o, v) => o.SelectedItem = v,
defaultBindingMode: BindingMode.TwoWay); defaultBindingMode: BindingMode.TwoWay);
/// <summary> /// <summary>
@ -88,7 +88,7 @@ namespace Avalonia.Controls.Primitives
/// </summary> /// </summary>
public static readonly RoutedEvent<RoutedEventArgs> IsSelectedChangedEvent = public static readonly RoutedEvent<RoutedEventArgs> IsSelectedChangedEvent =
RoutedEvent.Register<SelectingItemsControl, RoutedEventArgs>( RoutedEvent.Register<SelectingItemsControl, RoutedEventArgs>(
"IsSelectedChanged", "IsSelectedChanged",
RoutingStrategies.Bubble); RoutingStrategies.Bubble);
/// <summary> /// <summary>
@ -96,7 +96,7 @@ namespace Avalonia.Controls.Primitives
/// </summary> /// </summary>
public static readonly RoutedEvent<SelectionChangedEventArgs> SelectionChangedEvent = public static readonly RoutedEvent<SelectionChangedEventArgs> SelectionChangedEvent =
RoutedEvent.Register<SelectingItemsControl, SelectionChangedEventArgs>( RoutedEvent.Register<SelectingItemsControl, SelectionChangedEventArgs>(
"SelectionChanged", "SelectionChanged",
RoutingStrategies.Bubble); RoutingStrategies.Bubble);
private static readonly IList Empty = new object[0]; private static readonly IList Empty = new object[0];
@ -521,7 +521,7 @@ namespace Avalonia.Controls.Primitives
else if (multi && range) else if (multi && range)
{ {
SynchronizeItems( SynchronizeItems(
SelectedItems, SelectedItems,
GetRange(Items, SelectedIndex, index)); GetRange(Items, SelectedIndex, index));
} }
else else
@ -583,7 +583,7 @@ namespace Avalonia.Controls.Primitives
} }
/// <summary> /// <summary>
/// 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. /// belongs to the control.
/// </summary> /// </summary>
/// <param name="eventSource">The control that raised the event.</param> /// <param name="eventSource">The control that raised the event.</param>
@ -595,7 +595,7 @@ namespace Avalonia.Controls.Primitives
/// false. /// false.
/// </returns> /// </returns>
protected bool UpdateSelectionFromEventSource( protected bool UpdateSelectionFromEventSource(
IInteractive eventSource, IInteractive eventSource,
bool select = true, bool select = true,
bool rangeModifier = false, bool rangeModifier = false,
bool toggleModifier = false) bool toggleModifier = false)
@ -807,12 +807,10 @@ namespace Avalonia.Controls.Primitives
SelectedIndex = -1; SelectedIndex = -1;
} }
} }
else
foreach (var item in e.OldItems)
{ {
foreach (var item in e.OldItems) MarkItemSelected(item, false);
{
MarkItemSelected(item, false);
}
} }
removed = e.OldItems; removed = e.OldItems;

Loading…
Cancel
Save