WPF Support

ReoGrid can work with both Windows Form and WPF. The core of ReoGrid works for both platform, there are independent view modules for rendering and handling user interface on each platform. The APIs of control that faced to user code are almost the same. User code that uses ReoGrid graphics interface for rendering custom cell or handling user event in cell can work on different platform.


Same one template file such as Excel or RGF that can display on Windows Form platform as well as WPF platform. Below are the results from different platforms that uses same template (order_sample.rgf).


As the result ReoGrid tries to keep almost the same appearance for different platforms.

Add spreadsheet control in XAML

Add ReoGrid DLL reference for target project, edit the XAML file of main window as below:

File MainWindow.xaml:

  x:Class="WPFDemo.MainWindow" Title="MainWindow" Height="640" Width="800">

    <rg:ReoGridControl x:Name="grid" >


Make sure the namespace is declared in the attribute list, then define a ReoGridControl tag inside Grid tag, run the application, an empty spreadsheet will be displayed in window like below:


In code behind, write code to call APIs of worksheet in order to set same example data and styles:

// get current worksheet instance
var worksheet = grid.CurrentWorksheet;

// get a range reference
var range = worksheet.Ranges["B2:C3"];

// merge the range

// set range styles
range.Style.BackColor = Graphics.SolidColor.LightYellow;
range.BorderOutside = RangeBorderStyle.BlackSolid;

// set range inner data
range.Data = "Hello World!";



The APIs of WPF edition is totally same as the Windows Form edition, see documentation for more details.

Load a template spreadsheet file

Set attribute LoadFromFile to load a template spreadsheet from file:

<rg:ReoGridControl LoadFromFile="order_sample.rgf" x:Name="grid" >

By run this sample the template spreadsheet will be displayed. It is possible to fill the data in a specified range by code after loading:

public MainWindow()

  grid.CurrentWorksheet.FileLoaded += CurrentWorksheet_FileLoaded;

void CurrentWorksheet_FileLoaded(object sender, unvell.ReoGrid.Events.FileLoadedEventArgs e)
  var worksheet = grid.CurrentWorksheet;
  var dataRange = worksheet.Ranges["A21:G35"];
  dataRange.Data = new object[,]
    {"[23423423]", "Product ABC", 15, 150, 2250},
    {"[45645645]", "Product DEF", 1, 75, 75},
    {"[78978978]", "Product GHI", 2, 30, 60},


Learn more about new features in 0.8.7.


One Response to “WPF Support”

  1. Vladimir Chernya says:

    Can you please provide the example of data binding to ObservableCollection if possible. Thanks.