diff --git a/src/Avalonia.Controls.TreeDataGrid/Primitives/RealizedStackElements.cs b/src/Avalonia.Controls.TreeDataGrid/Primitives/RealizedStackElements.cs index d0d1f8b1..e216f771 100644 --- a/src/Avalonia.Controls.TreeDataGrid/Primitives/RealizedStackElements.cs +++ b/src/Avalonia.Controls.TreeDataGrid/Primitives/RealizedStackElements.cs @@ -489,9 +489,8 @@ public void RecycleElementsAfter(int index, Action recycleElement) else { var startIndex = (index + 1) - FirstIndex; - var count = _elements.Count; - for (var i = startIndex; i < count; ++i) + for (var i = startIndex; i < _elements.Count; ++i) { if (_elements[i] is Control e) {