Browse Source

Throw if setting ItemsSource when Items present.

pull/10590/head
Steven Kirk 3 years ago
parent
commit
ddacc112ac
  1. 4
      src/Avalonia.Controls/ItemCollection.cs

4
src/Avalonia.Controls/ItemCollection.cs

@ -121,6 +121,10 @@ namespace Avalonia.Controls
internal void SetItemsSource(IEnumerable? value)
{
if (_mode != Mode.ItemsSource && Count > 0)
throw new InvalidOperationException(
"Items collection must be empty before using ItemsSource.");
_mode = value is not null ? Mode.ItemsSource : Mode.Items;
SetSource(value ?? CreateDefaultCollection());
}

Loading…
Cancel
Save