sgcGrid, the WPF DataGrid for Live Data
A WPF DataGrid control that binds your view model in XAML and keeps up with data that never sits still.
A WPF DataGrid control that binds your view model in XAML and keeps up with data that never sits still.
This C# data grid updates rows by key from any thread, flashes the cells that change, and groups, totals, filters and exports the same rows. TsgcWpfGrid lives in the esegece.sgcGrid.Wpf package. It is a managed C# port of the sgcGrid engine, not a wrapper, and it paints with the .NET port of sgcUICore, so the grid looks the same on WPF, WinForms, Avalonia and in headless PNG and SVG output.
TsgcGridData is keyed and thread safe: a worker thread appends, updates and deletes rows by key with AppendRow, UpdateRow and DeleteRowMaxFPS times per second, however fast the data changesFlashChanges tints each changed cell green or red and fades it outFormatRules colour a cell or, with ApplyToRow, the whole row, for example every row with a negative changeItemsSource, changes of the collection and of the items update only the rows involved, and changes raised on a worker thread are applied on the UI threadGroup by one or more columns from code with GroupBy, or let users drag a header to the group panel. Sum, Count, Average, Min and Max appear on every group row and in the footer, and FrozenColumns keeps the key columns in view.
A filter button on every header, a filter row, a find panel that highlights the matches, the filter builder, the column chooser and best fit. On WPF these options are dependency properties, so you set them in XAML, bind them and style them.
SaveToXLSX writes the view as an Excel workbook with no Excel installation and no external library, with the column widths and the frozen columns as a frozen pane. JSON and CSV export are in every edition. Excel export is Registered.
Virtual mode serves the values on demand through OnGetValue, for millions of rows that are never loaded. Server mode pages a database: TsgcGridServerProvider_Queryable reads any IQueryable, an Entity Framework Core set for example (Registered).
Show rows as a tree built from a key and a parent field, or open a detail band under a master row with its child rows from a second source. Tree rows and master detail are in the Registered edition.
Light and dark themes, an accent colour, and the Classic, Fluent and ISA101 presets. With Theme left at utDefault, the grid follows the light or dark theme of WPF and its accent colour while the application runs.
The screenshots come from the sgcGrid and sgcUI demos. The WPF grid draws with the same canvas, fonts and themes, and it draws its own scroll bars.
100,000 orders in two group levels, with summaries on every group row and in the footer.
Header filters, a filter row and the find panel on 100,000 rows.
Format rules tint overdue rows and set large amounts in bold.
Virtual mode: 5,000,000 log rows, values served on demand.
The dark theme, with a date editor open in a cell (in-place editing is Registered).
sgcGrid in a business screen of the Altamira ERP demo.
Two ways to fill the grid: bind ItemsSource to a collection of your view model, or write keyed rows from code, from any thread.
Create a net8.0-windows WPF project with <UseWPF>true</UseWPF>, or a .NET Framework 4.7.2 project, and add the free Community package from nuget.org. The core and rendering packages come with it as dependencies.
dotnet add package esegece.sgcGrid.Wpf.CommunityThe Registered package is esegece.sgcGrid.Wpf. It is downloaded from your account, not from nuget.org: add its folder as a package source once. A project references either the Community or the Registered packages, never both.
Map the one sgcUI XAML namespace, xmlns:sgc="https://www.esegece.com/sgcui". Columns is the content property of TsgcWpfGrid, so the TsgcWpfGridColumn elements inside the grid become its columns, in order. Declared columns win: AutoGenerateColumns adds none.
<Window x:Class="OrdersApp.OrdersWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:OrdersApp"
xmlns:sgc="https://www.esegece.com/sgcui"
Title="Orders" Width="900" Height="500">
<Window.DataContext>
<local:OrdersViewModel />
</Window.DataContext>
<sgc:TsgcWpfGrid x:Name="grdOrders" ItemsSource="{Binding Orders}" KeyMember="Id"
RowHeight="26" ShowGroupPanel="True" ShowFooter="True" ShowFilterRow="True">
<sgc:TsgcWpfGridColumn FieldName="Id" Caption="Order" DataType="gdtInteger" Width="70" />
<sgc:TsgcWpfGridColumn FieldName="Region" Width="120" />
<sgc:TsgcWpfGridColumn FieldName="Customer" Width="180" />
<sgc:TsgcWpfGridColumn FieldName="Date" DataType="gdtDateTime" DisplayFormat="yyyy-mm-dd" Width="100" />
<sgc:TsgcWpfGridColumn FieldName="Total" DataType="gdtCurrency" DisplayFormat="#,##0.00"
SummaryType="gsuSum" />
<sgc:TsgcWpfGridColumn FieldName="Shipped" DataType="gdtBoolean" Width="70" Alignment="gaCenter" />
</sgc:TsgcWpfGrid>
</Window>Any IEnumerable works. Each item is a row, each column reads the member named by its FieldName, and an item that raises PropertyChanged updates its row only. The grid reads the collection through its collection view, so the SortDescriptions, the Filter and the PropertyGroupDescription entries of a CollectionViewSource apply too.
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows;
namespace OrdersApp
{
public class Order : INotifyPropertyChanged
{
private decimal FTotal;
public event PropertyChangedEventHandler PropertyChanged;
public int Id { get; set; }
public string Region { get; set; }
public string Customer { get; set; }
public DateTime Date { get; set; }
public bool Shipped { get; set; }
public decimal Total
{
get { return FTotal; }
set
{
FTotal = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(nameof(Total)));
}
}
}
public class OrdersViewModel
{
public ObservableCollection<Order> Orders { get; } = new ObservableCollection<Order>();
public OrdersViewModel()
{
Orders.Add(new Order { Id = 1001, Region = "North", Customer = "Ana", Date = new DateTime(2026, 10, 1), Total = 250m, Shipped = true });
Orders.Add(new Order { Id = 1002, Region = "South", Customer = "Ben", Date = new DateTime(2026, 10, 3), Total = 99.9m });
Orders.Add(new Order { Id = 1003, Region = "North", Customer = "Ana", Date = new DateTime(2026, 10, 7), Total = 1200m });
}
}
public partial class OrdersWindow : Window
{
public OrdersWindow()
{
InitializeComponent();
// group rows by region, then by customer; sums show on every group row
grdOrders.GroupBy("Region", "Customer");
}
}
}For a feed, skip the collection and write rows straight into the row store. Every row has a key, and UpdateRow changes the named fields of that row. The XAML is one line, <sgc:TsgcWpfGrid x:Name="grdQuotes" RowHeight="26" FlashChanges="True" />.
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using esegece.sgcGrid;
using esegece.sgcUICore;
namespace QuotesApp
{
public partial class QuotesWindow : Window
{
private readonly CancellationTokenSource FCancel = new CancellationTokenSource();
public QuotesWindow()
{
InitializeComponent();
// the columns: field name, caption and data type
grdQuotes.Columns.Add("symbol", "Symbol");
grdQuotes.Columns.Add("price", "Price", TsgcGridDataType.gdtFloat).DisplayFormat = "#,##0.00";
grdQuotes.Columns.Add("change", "Change", TsgcGridDataType.gdtFloat).DisplayFormat = "+0.00;-0.00;0.00";
// rows with a negative change are tinted red
grdQuotes.FormatRules.Add("change", TsgcGridFormatOperator.gfoLess, "0", 0x30E53935).ApplyToRow = true;
grdQuotes.Theme = TsgcUITheme.utDark;
// one row per key, the values follow the column order
grdQuotes.Data.AppendRow("MSFT", "MSFT", 412.5, 0.0);
grdQuotes.Data.AppendRow("AAPL", "AAPL", 228.1, 0.0);
TsgcGridData oData = grdQuotes.Data;
Task.Run(() => DoFeed(oData, FCancel.Token));
Closed += (s, e) => FCancel.Cancel();
}
// runs on a worker thread: TsgcGridData is thread safe
private static void DoFeed(TsgcGridData aData, CancellationToken aToken)
{
Random oRandom = new Random();
while (!aToken.IsCancellationRequested)
{
double vChange = Math.Round(oRandom.NextDouble() * 4 - 2, 2);
aData.UpdateRow("MSFT", new[] { "price", "change" }, new object[] { 412.5 + vChange, vChange });
Thread.Sleep(100);
}
}
}
}The changed cells flash and fade, and the repaints stay paced by MaxFPS. The step by step version is the WPF quick start, and the binding rules are in ItemsSource and MVVM binding and Columns in XAML.
Virtual mode (Virtual, VirtualRowCount, OnGetValue) serves the values on demand, so millions of rows never have to be loaded. In server mode a provider reads one page of rows at a time, and the database evaluates the sort, the filters, the find text, the summaries, the grouping and the row count. TsgcGridServerProvider_AdoNet runs the same SQL on any ADO.NET connection.
SelectedItem binds TwoWay by default, and the selection follows its item when the rows are sorted, filtered or reloaded. IsSynchronizedWithCurrentItem keeps the selected row and the current item of the collection view in step, as on a ListBox.
On .NET 9 and later, Application.ThemeMode Light, Dark or System decides between the light and dark grid. With the Fluent preset, sgcUIApplication.ThemePreset = sgcUICore_Theme.CS_UI_THEME_FLUENT, the WPF Fluent theme also gives the grid its colours. On .NET Framework 4.7.2 and .NET 8 the WPF host theme is light, and Theme switches the grid to dark.
The .NET demos include LiveTickerWpf, GroupingWpf, SpreadsheetWpf and ServerModeAndCardsWpf. A saved layout is the same JSON on the WPF, WinForms, Avalonia, VCL and FireMonkey grids.
Prices from the sgcGrid pricing page. Every license includes the full C# source code and 1 year of updates.
esegece.sgcGrid.Wpf.Community on nuget.org, for individuals and organizations under EUR 1M annual gross revenue with no more than 5 developers. Live updates, flashing, format rules, themes, sorting, filters, grouping, summaries, virtual mode, ItemsSource binding, JSON and CSV and printing are included.
€199 / developer for WinForms, WPF and Avalonia. Adds in-place editing, paste, undo and redo, tree rows, master detail, Excel export and Excel mode, server mode, the card view and the PDF export.
Buy sgcGrid .NET → Team and Site →sgcGrid with sgcNavigation, sgcToolbar and sgcEditors, from €380 per developer, with free binary redistribution.
See the sgcUI .NET editions →The C# classes keep the same names on every host, so code that fills Columns, Data and FormatRules moves between them.
| Host | Control | Targets | Binding |
|---|---|---|---|
| WPF | TsgcWpfGrid | net472, net8.0-windows, net9.0-windows, net10.0-windows | ItemsSource, collection views, XAML columns |
| WinForms | TsgcWinFormsGrid | net472, net8.0-windows, net9.0-windows, net10.0-windows | DataSource and DataMember |
| Avalonia 12 | TsgcAvaloniaGrid | net8.0, net9.0, net10.0 on Windows, Linux and macOS | ItemsSource, XAML columns |
| Headless | TsgcGridRenderer | netstandard2.0 and up, Linux servers included | PNG and SVG output |
Building for Linux and macOS as well? Read the Avalonia DataGrid page, or move a WinForms or WPF app to Avalonia. sgcGrid is also available for Delphi and C++Builder, on VCL and FireMonkey: see the sgcGrid product page.
Look for a grid that paints only what is visible and does not need every row in memory. sgcGrid paints only the visible rows and columns and repaints at most MaxFPS times per second. Virtual mode serves the values on demand through OnGetValue, and server mode reads one page of rows at a time from IQueryable or ADO.NET while the database sorts, filters, groups and counts. Virtual mode is in every edition; server mode is Registered.
Yes, in every edition, Community included. Group from code with GroupBy, by dragging a header to the group panel (ShowGroupPanel), or through the PropertyGroupDescription entries of a WPF collection view. Set SummaryType on a column to gsuSum, gsuCount, gsuAverage, gsuMin or gsuMax: the summary shows on every group row and, with ShowFooter, in the footer over all rows.
Yes, in the Registered edition. SaveToXLSX(fileName, sheetName) or its Stream overload writes the view as an .xlsx workbook with no Excel installation and no external library: the visible columns in their order, a bold header row, the column widths, and the frozen columns as a frozen pane. Sorting and filtering apply, so the workbook holds the rows the user sees. JSON and CSV export are in every edition.
Yes. The row store TsgcGridData is keyed and thread safe, so a worker thread can call AppendRow, UpdateRow and DeleteRow while the grid paints at a paced frame rate. With ItemsSource, changes raised on a worker thread are applied on the UI thread. In the Registered edition, the sgcWebSockets bridge also feeds the grid from WebSocket, MQTT and SSE connections.
Yes. One sgcGrid .NET license covers TsgcWinFormsGrid for WinForms, TsgcWpfGrid for WPF and TsgcAvaloniaGrid for Avalonia 12 on Windows, Linux and macOS, each with its own Community and Registered NuGet package. The three grids share the C# model and the layout JSON. Delphi and C++Builder developers get TsgcVCLGrid and TsgcFMXGrid under a Delphi license.
.NET Framework 4.7.2 and .NET 8, 9 and 10. The esegece.sgcGrid.Wpf package targets net472, net8.0-windows, net9.0-windows and net10.0-windows, and it brings the sgcEditors WPF controls that the grid uses as cell editors.