Skip to content

Commit

Permalink
Don't rely on VisibleColumnCount since it is updated later.
Browse files Browse the repository at this point in the history
  • Loading branch information
appel1 committed Apr 24, 2024
1 parent 10dec90 commit 9528477
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,19 @@ int IChildIndexProvider.GetChildIndex(ILogical child)

bool IChildIndexProvider.TryGetTotalCount(out int count)
{
count = OwningGrid.ColumnsInternal.VisibleColumnCount;
// VisibleColumnCount is updated the next measure pass after columns are added or removed
// but this is called as the column is being added or removed.
// count = OwningGrid.ColumnsInternal.VisibleColumnCount;

count = 0;
for (int i = 0; i < Children.Count; i++)
{
if (Children[i] is DataGridColumnHeader { OwningColumn: { IsVisible: true } and not DataGridFillerColumn })
{
count++;
}
}

return true;
}

Expand Down

0 comments on commit 9528477

Please sign in to comment.