Browse Source

Fix setting SelectedIndex in XAML

pull/3047/head
Benedikt Schroeder 7 years ago
parent
commit
bcbe9c3dbd
  1. 16
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

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

@ -304,6 +304,11 @@ namespace Avalonia.Controls.Primitives
{
base.ItemsCollectionChanged(sender, e);
if (_updateCount > 0)
{
return;
}
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
@ -1071,13 +1076,16 @@ namespace Avalonia.Controls.Primitives
private void UpdateFinished()
{
if (_updateSelectedIndex != int.MinValue)
if (_updateSelectedItem != null)
{
SelectedIndex = _updateSelectedIndex;
SelectedItem = _updateSelectedItem;
}
else if (_updateSelectedItem != null)
else
{
SelectedItem = _updateSelectedItem;
if (ItemCount > 0)
{
SelectedIndex = _updateSelectedIndex != int.MinValue ? _updateSelectedIndex : 0;
}
}
}

Loading…
Cancel
Save