Browse Source

Auto-select first item on `Reset`.

When a reset is received by `SelectingItemsControl` which has `AlwaysSelect == true`, select the first item if present.

Fixes #2754
pull/2771/head
Steven Kirk 7 years ago
parent
commit
397d972db8
  1. 5
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

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

@ -333,6 +333,11 @@ namespace Avalonia.Controls.Primitives
case NotifyCollectionChangedAction.Move:
case NotifyCollectionChangedAction.Reset:
SelectedIndex = IndexOf(Items, SelectedItem);
if (AlwaysSelected && SelectedIndex == -1 && ItemCount > 0)
{
SelectedIndex = 0;
}
break;
}
}

Loading…
Cancel
Save