Prevent to scroll to the top of the Row

3 posts, 0 answers
  1. Ludovic
    Ludovic avatar
    9 posts
    Member since:
    Oct 2015

    Posted 07 Apr Link to this post

    Hi,



    I use a RadGridView and when I click on a GridViewRow which is not entire visible, I scroll automatically.

    This is an illustration with the GridViewRow number 0, and the GridViewRow number 4, before and after a click.
    http://image.noelshack.com/fichiers/2016/14/1460041764-telerik2.png
    http://image.noelshack.com/fichiers/2016/14/1460041552-telerik3.png

    When I click on it, the ScrollViewer is called. And I don't want ! But impossible to prevent this comportment. Could you help me ?



    Thank you.
  2. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 12 Apr Link to this post

    Hello Ludovic,

    I am afraid that there is no out-of-the-box mechanism for achieving this. You can check out this forum thread for more information, however, I cannot confirm that the workaround suggested in it would be working as expected in all scenarios.

    All the best,
    Stefan X1
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ludovic
    Ludovic avatar
    9 posts
    Member since:
    Oct 2015

    Posted 12 Apr Link to this post

    Hi Stefan,

     

    Your thread has solved my issue. Indeed, this code prevents the unwanted behavior

     

    private void RadGridView_OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
    {
        if ((e.OriginalSource as GridViewScrollViewer) != null)
        {
            var scrollViewer = this.RadGridView.ChildrenOfType<GridViewScrollViewer>().FirstOrDefault();
            scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset);
        }
    }

     

    Thank you !

     

    Regards,

    Ludovic.

Back to Top