From 9d63dc2e4a1269fff8d8c7ebf7d89c60c17d168d Mon Sep 17 00:00:00 2001 From: xiaoy312 Date: Thu, 14 Nov 2024 12:43:25 -0500 Subject: [PATCH] fix(DataGrid): not displaying cells from last columns when resized from scrolled state --- .../DataGrid/DataGridColumns.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CommunityToolkit.WinUI.UI.Controls.DataGrid/DataGrid/DataGridColumns.cs b/CommunityToolkit.WinUI.UI.Controls.DataGrid/DataGrid/DataGridColumns.cs index 1e781019616..e15af032342 100644 --- a/CommunityToolkit.WinUI.UI.Controls.DataGrid/DataGrid/DataGridColumns.cs +++ b/CommunityToolkit.WinUI.UI.Controls.DataGrid/DataGrid/DataGridColumns.cs @@ -1245,6 +1245,14 @@ private bool ComputeDisplayedColumns() _horizontalOffset -= GetEdgedColumnWidth(dataGridColumn); dataGridColumn = this.ColumnsInternal.GetPreviousVisibleScrollingColumn(dataGridColumn); } + + if (_horizontalOffset == 0 && cx < displayWidth) + { + // if the columns have been scrolled, and all visible columns are fully rendered in the available space, + // then HorizontalAdjustment needs to be updated so that DataGridCellsPresenter.ShouldDisplayCell + // don't hide columns based on the old value. + HorizontalAdjustment = displayWidth - cx; + } } // third try to partially scroll in first scrolled off column