Maintain scroll position on treelistview page navigation

1 posts, 0 answers
  1. Manishkumar
    Manishkumar avatar
    240 posts
    Member since:
    Feb 2009

    Posted 04 Nov 2011 Link to this post

    Hi,

    I need to maintain scroll position (both horizontal and vertical) when moving across pages.
    I tried the following code , but was unable to achieve the desired functionality.
    Even after calling RestoreScrollPosition() the scrollviewer didn't change its position.


     

    private void btnNext_Click(object sender, RoutedEventArgs e)

     

    {

    SetScrollPosition();
    BindData();

    RestoreScrollPosition();

     

     

     

    }

     

     

    private void SetScrollPosition()

     

    {

     

    GridViewScrollViewer svSummaryInfo = (GridViewScrollViewer)rtSummaryInfo.FindChildByType<GridViewScrollViewer>();

     

     

     

    _dbVerticalOffset = svSummaryInfo.VerticalOffset;
    _dbHorizontalOffset = svSummaryInfo.HorizontalOffset;
    }

    private

     

    void RestoreScrollPosition()

     

    {

    GridViewScrollViewer

     

    svSummaryInfo = (GridViewScrollViewer)rtSummaryInfo.FindChildByType<GridViewScrollViewer>();

     

     

    if (svSummaryInfo != null)

     

      {

     

       svSummaryInfo.ScrollToHorizontalOffset(_dbHorizontalOffset);

       svSummaryInfo.ScrollToVerticalOffset(_dbVerticalOffset);

       }
    }

    Please provide a code snippet for the same.

     

Back to Top