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
<Window x:Class="HorzScroll.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:HorzScroll"
mc:Ignorable="d"
Title="MainWindow"
Height="900"
Width="1600">
<Grid>
<DataGrid Name="dataGrid"
AutoGenerateColumns="True"
EnableRowVirtualization="True"
EnableColumnVirtualization="True"
FrozenColumnCount="2"
/>
</Grid>
</Window>
MainWindow.xaml.cs
using System.Windows;
namespace HorzScroll;
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
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
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