Browse Source

Allow both SelectedItem and SelectedItems to be bound.

Fixes #2969.
pull/2970/head
Steven Kirk 7 years ago
parent
commit
25ebbd63be
  1. 10
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

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

@ -112,7 +112,7 @@ namespace Avalonia.Controls.Primitives
private bool _syncingSelectedItems; private bool _syncingSelectedItems;
private int _updateCount; private int _updateCount;
private int _updateSelectedIndex; private int _updateSelectedIndex;
private IList _updateSelectedItems; private object _updateSelectedItem;
/// <summary> /// <summary>
/// Initializes static members of the <see cref="SelectingItemsControl"/> class. /// Initializes static members of the <see cref="SelectingItemsControl"/> class.
@ -160,7 +160,7 @@ namespace Avalonia.Controls.Primitives
else else
{ {
_updateSelectedIndex = value; _updateSelectedIndex = value;
_updateSelectedItems = null; _updateSelectedItem = null;
} }
} }
} }
@ -183,7 +183,7 @@ namespace Avalonia.Controls.Primitives
} }
else else
{ {
_updateSelectedItems = new AvaloniaList<object>(value); _updateSelectedItem = value;
_updateSelectedIndex = int.MinValue; _updateSelectedIndex = int.MinValue;
} }
} }
@ -1075,9 +1075,9 @@ namespace Avalonia.Controls.Primitives
{ {
SelectedIndex = _updateSelectedIndex; SelectedIndex = _updateSelectedIndex;
} }
else if (_updateSelectedItems != null) else if (_updateSelectedItem != null)
{ {
SelectedItems = _updateSelectedItems; SelectedItem = _updateSelectedItem;
} }
} }

Loading…
Cancel
Save