New to Telerik UI for WPF? Download free 30-day trial

Getting Started

This tutorial will walk you through the required steps for using RadVirtualGrid.

Assembly References

In order to use RadVirtualGrid in your application, you need to add references to the following assemblies:

  • Telerik.Windows.Controls
  • Telerik.Windows.Controls.VirtualGrid
  • Telerik.Windows.Data

Adding RadVirtualGrid to the Project

Example 1: Defining RadVirtualGrid Declaratively

 <telerik:RadVirtualGrid x:Name="VirtualGrid"/> 

Populating with Data through DataProvider

When populating data with a DataProvider, it handles most of the operations of RadVirtualGrid out-of-the-box. Thus, the events that are intended to be used for manually populating and manipulating the data of the control will not be raised.

Instead of using the CellValueNeeded event, RadVirtualGrid provides an option to populate its data through the built-in DataProvider mechanism. The DataProvider object accepts an IEnumerable through its constructor and can be applied to RadVirtualGrid through its relevant property.

Example 4: Applying a DataProvider

this.VirtualGrid.DataProvider = new Telerik.Windows.Controls.VirtualGrid.DataProvider(this.myCollection); 

The DataProvider mechanism is intended to cover basic scenarios for populating the control with data. For extending the default behavior, RadVirtualGrid provides support for Custom DataProvider

Populating with data manually

In order the control to be populated with data, its InitialRowCount and InitialColumnCount properties need to be set.

RadVirtualGrid needs to be initially defined with a fixed amount of rows and columns. The below listed properties are exposed for achieving this. An important note is that when additional rows or columns are added at runtime, the values of these properties remain unmodified, but the capacity of the control increases. More information on inserting rows and columns can be found in the Insert and Remove Data topic.

  • InitialRowCount: Gets or sets the amount of initially loaded rows

  • InitialColumnCount: Gets or sets the amount of initially loaded columns

Example 2: Setting the InitialRowCount and InitialColumnCount properties

<telerik:RadVirtualGrid x:Name="VirtualGrid"  
The control populates its data through the CellValueNeeded event. It is raised when the control is initially loaded and when newly data is about to be loaded on demand when the user scrolls horizontally or vertically. The event arguments expose the following properties:


  • CellIndex: Provides information regarding the index of the currently loaded cell.

  • RowIndex: Provides information regarding the index of the currently loaded row.

  • Value: Through it the needed value for the respective cell can be set.

Example 3: Populating RadVirtualGrid with data through the CellValueNeeded event

private void virtualGrid_CellValueNeeded(object sender,  
        Telerik.Windows.Controls.VirtualGrid.CellValueEventArgs e) 
        e.Value = String.Format("{0}.{1}", e.RowIndex, e.ColumnIndex); 

Figure 1: RadVirtualGrid populated with data

RadVirtualGrid populated with data


This property indicates whether the text is measured on rendering. Its default value is False. When set to True, the usage of the FitColumnWidthToContent and CellTextAlignment mechanisms is enabled. Note, that this may affect the performance of the control.

See also

In this article
Not finding the help you need? Improve this article