dotnet / dotnet/wpf

DataGrid janky scroll for large data

Open
#10,444 2 comments 1 reaction 0 assignees View on GitHub
area-DataGrid Investigate Performance
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

Hello,

When rendering a datagrid with lots of columns, say 1000 and 100k rows.
The scrolling performance is very janky for at larger window sizes even with row and column virtualization on.

### Reproduction Steps

MainWindow.xaml
```xaml



```

MainWindow.xaml.cs
```csharp
using System.Windows;

namespace HorzScroll;
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
LoadData();
}

private void LoadData()
{
var dataTable = new System.Data.DataTable();

var nColumns = 1000;
var nRows = 100000;

// Add 1000 columns
for (int i = 0; i < nColumns; i++)
{
dataTable.Columns.Add("Column" + i);
}

// Add 1000 rows
for (int i = 0; i < nRows; i++)
{
var row = dataTable.NewRow();
for (int j = 0; j < nColumns; j++)
{
row[j] = $"R{i}C{j}";
}
dataTable.Rows.Add(row);
}

dataGrid.ItemsSource = dataTable.DefaultView;
}

}
```

### Expected behavior

I would expect the datagrid to have fast scrolling.

### Actual behavior

Janky scrolling when using the scrollbars.

### Regression?

_No response_

### Known Workarounds

[https://github.com/obiben/DynamicGridControl](url)

This is a link to dynamic grid control example that is smooth to any data sizes with no jankiness with horizontal scroll but lacks the functionality of the datagrid.

It uses building a 2-dimensional item cache for fast lookup during scrolling and recycling display data only when necessary. The performance is exceptional at any screen size.

### Impact

_No response_

### Configuration

.NET 9
Windows 11
x64
It is not specific to this configuration.

### 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.