wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Column virtualization in DataGrid with GroupStyle hides column headers when empty

Open cbra-caa opened this issue 9 months ago • 0 comments

Description

Based on the following discussion: https://github.com/dotnet/wpf/discussions/10774

The problem is that when a DataGrid with a group style, but without any initial rows is rendered, the column headers are does not show. After an initial set of rows has been added the headers display as expected, even if the rows are cleared again.

The problem reappears if the ItemsSource is changed causing grouping to be reapplied. This is f.ex. the case when running with a mvvm structure where the datagrid hosts different content based on a folder structure.

Reproduction Steps

Setup:

  • All columns in my DataGrid have a set width
  • EnableColumnVirtualization is set to true
  • A groupstyle has been added to the datagrid.

DataGridColumnVirtualization.zip

  1. Run the program 'as is', observe that no column headers are rendered
  2. Add an item through the context menu, column headers appear
  3. Remove the item again, column headers stay

Expected behavior

I would expect the column headers to be initially rendered, as they do so when no GroupStyle is present

Actual behavior

No column headers are shown initially

Regression?

Not that I know of

Known Workarounds

Deferring the GroupStyle till after items has been added seems to fix the problem, see https://github.com/dotnet/wpf/discussions/10774#discussioncomment-12843129

Impact

Reduces the usability of the datagrid for complex data structures where multiple columns and groupings are needed to give an overview.

Configuration

.NET Framework 4.8 Windows 11 Pro, v26100.3775 64-bit operating system, x64-based processor

Other information

No response

cbra-caa avatar Apr 16 '25 09:04 cbra-caa