Blog

WPF DataGrid slow? Virtualizing rows is not enough

· Michael Fellinger

Your WPF DataGrid stutters with a lot of data, and you have already turned on everything that says "virtualization". Virtualizing rows is a solved problem. The real question is what happens with the columns, with layout, and in every single frame. This article gives you the fixes that help inside WPF, then describes the standard we build ArionUI to: Total Virtualization.

Why a virtualized DataGrid can still be slow

The DataGrid has row virtualization and container recycling on by default, so only rows in view get elements. Those rows are still small trees of elements: a DataGridRow, a DataGridCell per column, and a TextBlock with a binding in each text cell. Styling, binding, measure and arrange for them all run on the UI thread, which also handles your clicks and keystrokes.

Columns get less help. EnableColumnVirtualization exists, but it is off by default, so a wide table can realize every cell of each visible row, including those far off to the right.

What helps inside WPF

Check these first. They cost little, and for a modest table they may be all you need.

What these settings leave in place: each visible cell is still a set of elements on the UI thread. A sort or filter through a ListCollectionView still goes through the items on the calling thread. And "no WPF controls offer built-in support for data virtualization", in Microsoft's words.

Total Virtualization

Virtualizing rows is something any serious grid does, and the WPF DataGrid can virtualize columns too when you switch it on. But a grid built from WPF elements per cell carries the cost of that model for every cell it realizes: elements, bindings, layout. Scrolling sideways means realizing or recycling a column of elements across all visible rows. No setting escapes that, because the grid is built on that model.

ArionUI has no per-cell elements at all. This is a different approach, not a better setting. We call the standard behind it Total Virtualization:

Row and column counts do not decide how much a frame lays out and draws. The visible area does.

The grid does keep a list of column widths, and it reads that list for bookkeeping, such as finding where the window starts. That is arithmetic over numbers, not a cell laid out or a string drawn, and a change of layout, such as a resized column, solves the widths again. A wide table costs that bookkeeping, not cells it does not show.

Built for the GPU

ArionUI clearly bets on the GPU, and Total Virtualization is designed around it. Plain table cells (backgrounds, value scales and text) go to the GPU in one instanced draw call from ArionUI's own shader program. On WPF, Skia draws through ANGLE on Direct3D 11 on the grid's own render thread, so drawing does not wait on the thread that handles your input.

Everything else is for emergencies and special cases such as a remote session without a GPU, and is not our focus. In such a case the WPF host keeps drawing through ANGLE, which can land on a software rasterizer, while the Avalonia host has a CPU path that repaints only the newly exposed strip. The window of rows and columns is the same, and RendererName tells you which adapter drew.

Total Virtualization on WPF

The ArionUI data grid comes to WPF as ArionGrid, a FrameworkElement you can put in any panel. On Windows it presents its frames itself, on a DirectComposition visual over the window. WPF content cannot be drawn over it (airspace), popups can; see Hosting and rendering.

Terminal
dotnet add package ArionUI.Rendering.Wpf --prerelease
MainWindow.xaml.cs (WPF)
using ArionUI.Core;               // ListItemsSource
using ArionUI.Presentation;       // GridView, Column, TypedColumn, ArionTheme
using ArionUI.Rendering.Wpf;      // ArionGrid for WPF

public sealed record Order(int Id, string Customer, double Amount);

public partial class MainWindow : Window
{
    public MainWindow(IReadOnlyList<Order> orders)   // a million rows, or ten
    {
        InitializeComponent();

        var view = new GridView<Order>(
            [
                TypedColumn.Number<Order>("Id", o => o.Id, format: "0").WithKey("id").WithWidth(80),
                Column.Text<Order>("Customer", o => o.Customer).WithKey("customer").WithWidth(180),
                TypedColumn.Number<Order>("Amount", o => o.Amount, format: "N2").WithKey("amount"),
            ],
            new ListItemsSource<Order>(orders),   // wraps the list, does not copy it
            rowHeight: 24)
            .AsDataGrid();

        Content = new ArionGrid(view) { VisualTheme = ArionTheme.Light() };
    }
}

Columns are declared in code on a view. A view model can expose the view, and XAML binds it to MainView. For rows that are not in memory, VirtualItemsSource and RemoteItemsSource fetch pages in the background, and the second lets the server sort and filter.

What was measured

We measured the WPF host at three sizes, from a small table up to a million columns by a hundred million rows. The window was maximized, and the script scrolled vertically and horizontally at the left edge, the middle and the far right.

WPF host, ArionGrid20 columns × 1,000 rows20,000 × 1,000,0001,000,000 × 100,000,000
Frame cost, scrolling vertically (median)0.86 ms1.04 ms1.02 ms
Frame cost, scrolling horizontally at the far right (median)(too narrow to scroll far)1.00 ms1.00 ms
Every frame on time at 60 Hz (median interval)16.6 ms16.5 ms16.6 ms
Time to first picture1.0 s0.7 s5.4 s
Managed memory35 MB77 MB1.84 GB

Median of the best of three runs. Intel laptop GPU (i7-11800H, UHD Graphics) through ANGLE on Direct3D 11, grid 1920 × 1129, 60 Hz display, column width 100, computed read-only data, Release build. Measured on 31 October 2026 on 0.1.0-preview.2.

From twenty thousand cells to a hundred trillion, the cost of a frame stays at about a millisecond, and it does not depend on how far to the right you have scrolled. That is Total Virtualization in numbers. What does grow with the column count is setting the columns up: a million column definitions take about five seconds to build and close to two gigabytes of memory, once, before the first picture. Scrolling is not where that cost lands. We have not measured a side-by-side with the WPF DataGrid. FrameRendered lets you measure your own screen in a Release build:

Measuring your own grid
var grid = new ArionGrid(view);
grid.FrameRendered += stats => Debug.WriteLine($"{stats.FrameMs:0.00} ms, {stats.DrawnSlots} rows drawn");

Data work is separate

Total Virtualization is about the frame. Work on the data itself is a different matter: sorting and filtering visit the rows when the query changes, once and not per frame, reordering indexes without copying your items. Auto-size measures the text of the column. Performance lists what grows with your data and what stays in your hands, such as keeping column code cheap.

What to know before you try it

Where to start

Try the WPF settings above first, since one of them may solve your problem. If you want a grid where the row and column counts stop deciding what a frame does, start with one screen: Install and first grid shows the setup. If the grid is part of an older application, Modernise your WinForms or WPF app describes how to replace it piece by piece.