Skip to content

Commit

Permalink
If we have no rows, get width from the columns.
Browse files Browse the repository at this point in the history
Fixes horizontal scrollbar disappearing when all rows removed.
  • Loading branch information
grokys committed Dec 3, 2024
1 parent 4d3933b commit 56eff20
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ protected override void UnrealizeElementOnItemRemoved(Control element)
ChildIndexChanged?.Invoke(this, new ChildIndexChangedEventArgs(element, ((TreeDataGridRow)element).RowIndex));
}

protected override Size MeasureOverride(Size availableSize)
{
var result = base.MeasureOverride(availableSize);

// If we have no rows, then get the width from the columns.
if (Columns is not null && (Items is null || Items.Count == 0))
result = result.WithWidth(Columns.GetEstimatedWidth(availableSize.Width));

return result;
}

protected override Size ArrangeOverride(Size finalSize)
{
Columns?.CommitActualWidths();
Expand Down

0 comments on commit 56eff20

Please sign in to comment.