Browse Source

Fix SelectingItemsControl multiple selection.

- Allow `SelectAll` regardless of `SelectionMode`: `SelectionMode` should only apply to user-interaction
- Don't select multiple on shift/ctrl-right click
pull/2702/head
Steven Kirk 7 years ago
parent
commit
afa38852cf
  1. 16
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

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

@ -469,11 +469,6 @@ namespace Avalonia.Controls.Primitives
/// </summary>
protected void SelectAll()
{
if ((SelectionMode & (SelectionMode.Multiple | SelectionMode.Toggle)) == 0)
{
throw new NotSupportedException("Multiple selection is not enabled on this control.");
}
UpdateSelectedItems(() =>
{
_selection.Clear();
@ -523,7 +518,14 @@ namespace Avalonia.Controls.Primitives
var toggle = (toggleModifier || (mode & SelectionMode.Toggle) != 0);
var range = multi && rangeModifier;
if (range)
if (rightButton)
{
if (!_selection.Contains(index))
{
UpdateSelectedItem(index);
}
}
else if (range)
{
UpdateSelectedItems(() =>
{
@ -582,7 +584,7 @@ namespace Avalonia.Controls.Primitives
}
else
{
UpdateSelectedItem(index, !(rightButton && _selection.Contains(index)));
UpdateSelectedItem(index);
}
if (Presenter?.Panel != null)

Loading…
Cancel
Save