Get scroll position

8 posts, 0 answers
  1. Philip
    Philip avatar
    40 posts
    Member since:
    Jan 2008

    Posted 09 Jul 2010 Link to this post

    Hi!

    Is there a possibility to find out the actual scroll position of the GridView? The matter is that I rebind the datasource und therefore the Grid looses the actual scroll position and jumps to the first item.

    I experienced a bit with ScrollViewer and ScrollContentPresenter but couldnt find a solution!

    Greetings
    Philip
  2. Ваня
    Ваня avatar
    35 posts
    Member since:
    Nov 2008

    Posted 10 Jul 2010 Link to this post

    Hi,Philip

    See the following thread I think that it could be useful for you:
    http://www.telerik.com/community/forums/silverlight/gridview/get-scrollbar-position-and-then-set-it.aspx


    Regards,Vanya
  3. Aryn
    Aryn avatar
    9 posts
    Member since:
    Jul 2014

    Posted 15 Nov 2014 in reply to Ваня Link to this post

    The thread has a link to a disabled page. Can you please provide another example? Thank you!
  4. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 17 Nov 2014 Link to this post

    Hello Aryn,


    Thank you for contacting us.

    This forum post referrs to the following blog post "How To: Custom scrolling with RadGridView for Silverlight and WCF RIA Services".

    For WPF you could take a look at the following post. 

    Are you looking for something similar?


    Regards,
    Vanya Pavlova
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  5. Aryn
    Aryn avatar
    9 posts
    Member since:
    Jul 2014

    Posted 17 Nov 2014 in reply to Vanya Pavlova Link to this post

    The WPF post (you posted) led me to the silverlight one. Unfortunately, I cannot do what the WPF user did. I must rebind my data set. I have tried very hard to read the scroll bar position and reset it but it seems to only do this accurately when I am debugging. Otherwise it jumps randomly all over my 2000 + record set uncontrollably.

    The code I used was:
    var scrollViewer = this.GridView.ChildrenOfType<GridViewScrollViewer>().FirstOrDefault();
                //Get horizontal and vertical offsets
                var horizontalOffset = scrollViewer.HorizontalOffset;
                var verticalOffset = scrollViewer.VerticalOffset;

                //do edit and rebind
                LoadTablesAndGrid();

                //Set horizontal and vertical offsets    
                scrollViewer.ScrollToHorizontalOffset(horizontalOffset);
                scrollViewer.ScrollToVerticalOffset(verticalOffset);




  6. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 20 Nov 2014 Link to this post

    Hello Phillip,


    I believe that the following forum thread "RadGridView scroll position reset after Rebind()" might be of help on that matter. 


    Regards,
    Vanya Pavlova
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Aryn
    Aryn avatar
    9 posts
    Member since:
    Jul 2014

    Posted 20 Nov 2014 in reply to Vanya Pavlova Link to this post

    Phillip,

    Thanks for the suggested post but if you notice that is exactly what I tried. When I do that it works when I am debugging otherwise it throws me all over my 2000+ records. I have found a hack solution that will get me by that hacks the ScrollIntoView but unfortunately it looks to me that you cannot reliably rely on the ScrollViewer to return you to your same location in the grid.

    Thanks,
    Aryn
  8. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 21 Nov 2014 Link to this post

    Hi,

    You can try saving the state of the ScrollViewer (VerticalOffset) and apply it after you have called Rebind().

    For example:
    scrollViewer =this.clubsGrid.ChildrenOfType<GridViewScrollViewer>().FirstOrDefault();
       
    var verticalOffset = scrollViewer.VerticalOffset;
    //reset of the itemssource
    //Set vertical offset back
    ...

    You can also check this forum thread where this question has already been discussed.

    Does this result in an uncontrollable scroll behavior?

    Regards,
    Dimitrina
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top