diff --git a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs index b97f2a2bcb..7c81c90d82 100644 --- a/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs +++ b/src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs @@ -3275,7 +3275,7 @@ namespace Avalonia.Collections addIndex); // next check if we need to add an item into the current group - // bool needsGrouping = false; + bool needsGrouping = false; if (Count == 1 && GroupDescriptions.Count > 0) { // if this is the first item being added @@ -3302,7 +3302,7 @@ namespace Avalonia.Collections // otherwise, we need to validate that it is within the current page. if (PageSize == 0 || (PageIndex + 1) * PageSize > leafIndex) { - //needsGrouping = true; + needsGrouping = true; int pageStartIndex = PageIndex * PageSize; @@ -3340,6 +3340,13 @@ namespace Avalonia.Collections } } + // if we need to add the item into the current group + // that will be displayed + if (needsGrouping) + { + this._group.AddToSubgroups(addedItem, false /*loading*/); + } + int addedIndex = IndexOf(addedItem); // if the item is within the current page