diff --git a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs
index 0026c9e074..d21a7bdb3f 100644
--- a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs
+++ b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs
@@ -54,7 +54,7 @@ namespace Avalonia.Collections
///
/// DataGrid-readable view over an IEnumerable.
///
- public sealed class DataGridCollectionView : IDataGridCollectionView, IDataGridEditableCollectionView, INotifyPropertyChanged
+ public sealed class DataGridCollectionView : IDataGridCollectionView, IDataGridEditableCollectionView, IList, INotifyPropertyChanged
{
///
/// Since there's nothing in the un-cancelable event args that is mutable,
@@ -1153,6 +1153,17 @@ namespace Avalonia.Collections
get { return GetItemAt(index); }
}
+ bool IList.IsFixedSize => false;
+ bool IList.IsReadOnly => true;
+ bool ICollection.IsSynchronized => false;
+ object ICollection.SyncRoot => this;
+
+ object IList.this[int index]
+ {
+ get => this[index];
+ set => throw new NotSupportedException();
+ }
+
///
/// Add a new item to the underlying collection. Returns the new item.
/// After calling AddNew and changing the new item as desired, either
@@ -3981,6 +3992,11 @@ namespace Avalonia.Collections
}
}
+ int IList.Add(object value) => throw new NotSupportedException();
+ void IList.Clear() => throw new NotSupportedException();
+ void IList.Insert(int index, object value) => throw new NotSupportedException();
+ void ICollection.CopyTo(Array array, int index) => InternalList.CopyTo(array, index);
+
///
/// Creates a comparer class that takes in a CultureInfo as a parameter,
/// which it will use when comparing strings.
diff --git a/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs b/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs
index ee9cc04420..fc9aac0ab8 100644
--- a/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs
+++ b/src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs
@@ -193,18 +193,17 @@ namespace Avalonia.Controls
}
}
- /// Try get number of DataSource itmes.
+ /// Try get number of DataSource items.
/// When "allowSlow" is false, method will not use Linq.Count() method and will return 0 or 1 instead.
/// If "getAny" is true, method can use Linq.Any() method to speedup.
- /// number of DataSource itmes.
- /// true if able to retrieve number of DataSource itmes; otherwise, false.
+ /// number of DataSource items.
+ /// true if able to retrieve number of DataSource items; otherwise, false.
internal bool TryGetCount(bool allowSlow, bool getAny, out int count)
{
bool result;
(result, count) = DataSource switch
{
ICollection collection => (true, collection.Count),
- DataGridCollectionView cv => (true, cv.Count),
IEnumerable enumerable when allowSlow && !getAny => (true, enumerable.Cast