How to scroll the SfDataGrid when we load within ScrollViewer using arrow keys?


3 Replies

JG Jai Ganesh S Syncfusion Team April 10, 2018 04:02 AM UTC

Hi Ariel, 
 
You can achieve your requirement to scroll the datagrid items using arrow keys while loading the datagrid inside the scroll viewer by override the ProcessKeyDown method in SelectionController like below, 
 
protected override void ProcessKeyDown(KeyEventArgs args) 
{ 
    var scrollviewer = Application.Current.MainWindow.FindName("scrollviewer") as ScrollViewer; 
    base.ProcessKeyDown(args); 
             
    if (args.Key == Key.Down  ) 
    { 
        scrollviewer.ScrollToVerticalOffset(scrollviewer.VerticalOffset + 24); 
    } 
    else if(args.Key == Key.Up ) 
    { 
        scrollviewer.ScrollToVerticalOffset(scrollviewer.VerticalOffset - 24); 
    } 
} 
 
 
In the above sample, we have increase/decrease the Vertical Offset value of scroll viewer as 24. Likewise, you can set the VerticalOffset value based on your requirement in your application. 
 
Regards, 
Jai Ganesh S


AR Ariel April 10, 2018 06:31 AM UTC

Hi Jai Ganesh

Thanks for the helping me to solved my problem. 

Thanks again


JG Jai Ganesh S Syncfusion Team April 11, 2018 04:16 AM UTC

Hi Ariel,  
 
Thank you for the update. 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Jai Ganesh S 


Loader.
Up arrow icon