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

Programmatic Scrolling

RadDataGrid exposes methods for programmatic scrolling to a specific column, a specific row index or a specific data item:

  • ScrollColumnIntoView(DataGridColumn column): Attempts to bring the specified DataGridColumn into view asynchronously.
  • ScrollIndexIntoView(int index): Attempts to bring the data item at the specified zero-based index into view asynchronously.
  • ScrollItemIntoView(object item): Attempts to bring the specified data item into view asynchronously.

Example

Examples 1, 2 and 3 demonstrate how to use these methods in practice.

Example 1: Creating a RadDataGrid in xaml

<telerikGrid:RadDataGrid x:Name="DataGrid" Width="200" RowHeight="50" Height="80" /> 

Example 2: Populating the RadDataGrid with sample data

public class Data 
{ 
    public string Country { get; set; } 
 
    public int Population { get; set; } 
 
    public string Capital { get; set; } 
} 
 
public MainPage() 
{ 
    this.InitializeComponent(); 
 
 
    List<Data> dataList = new List<Data> 
    { 
        new Data { Country = "Argentina", Population = 41300000, Capital = "Buenos Aires" }, 
        new Data { Country = "France", Population = 65350000, Capital = "Paris" }, 
        new Data { Country = "Japan", Population = 26700000, Capital = "Tokyo" }, 
        new Data { Country = "Spain", Population = 47300000, Capital = "Madrid" }, 
        new Data { Country = "Germany", Population = 82000000, Capital = "Berlin" }, 
        new Data { Country = "Egypt", Population = 90000000, Capital = "Cairo" }, 
        new Data { Country = "Bulgaria", Population = 7500000, Capital = "Sofia" }, 
        new Data { Country = "Switzerland", Population = 8000000, Capital = "Bern" }, 
        new Data { Country = "Canada", Population = 33500000, Capital = "Ottawa" }, 
        new Data { Country = "Russia", Population = 143300000, Capital = "Moscow" }, 
        new Data { Country = "Denmark", Population = 5600000, Capital = "Copenhagen" }, 
    }; 
    this.DataGrid.ItemsSource = dataList; 
} 

Example 3: Programmatic Scrolling

// Scroll(bring into View) to the third column of the DataGrid. 
this.DataGrid.ScrollColumnIntoView(this.DataGrid.Columns[2]); 
 
// Scroll(bring into View) to the twelfth row of the DataGrid. 
this.DataGrid.ScrollIndexIntoView(11); 
 
// Scroll(bring into View) to a specific data item from the data. 
this.DataGrid.ScrollItemIntoView(dataList[6]); 
In this article
Not finding the help you need?