dotnet / dotnet/wpf

Column virtualization in DataGrid with GroupStyle hides column headers when empty

Open
#10,779 1 comment 5 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### 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](https://github.com/user-attachments/files/19773875/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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.