Skip to content

Commit

Permalink
Correctly return early if no columns exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Dec 30, 2023
1 parent a14e64b commit e238055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Maui.DataGrid/DataGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,8 +1254,9 @@ private void InitHeaderView()
_headerView.Padding = new(BorderThickness.Left, BorderThickness.Top, BorderThickness.Right, 0);
_headerView.ColumnSpacing = BorderThickness.HorizontalThickness;

if (Columns == null)
if (Columns == null || Columns.Count == 0)
{
_headerView.ColumnDefinitions.Clear();
return;
}

Expand Down
6 changes: 6 additions & 0 deletions Maui.DataGrid/DataGridRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ private void CreateView()

SetStyling();

if (DataGrid.Columns == null || DataGrid.Columns.Count == 0)
{
ColumnDefinitions.Clear();
return;
}

for (var i = 0; i < DataGrid.Columns.Count; i++)
{
var col = DataGrid.Columns[i];
Expand Down

0 comments on commit e238055

Please sign in to comment.