RadiantQ WPF Gantt
How to persist the vertical scroll position?
Previous Topic  Next Topic 

How to persist the vertical scroll position?


Sometimes you want to save the current vertical scroll position and then set that position back again, after a refresh of the bound source, for example.


You can do so (partly) as follows:


        object topMostVisibleRowContext = null;

        private void SaveScrollState_Click(object sender, RoutedEventArgs e)

        {

               // This is a very expensive method, with the search peformance in O(n(pow)2)

            this.topMostVisibleRowContext = Extensions.GetFirstVisibleDataGridRow(this.ganttControl.GanttTable).DataContext;

        }


        private void LoadScrollState_Click(object sender, RoutedEventArgs e)

        {

            if (this.topMostVisibleRowContext != null)

            {

                this.ganttControl.GanttTable.SelectedItem = topMostVisibleRowContext;

                this.ganttControl.GanttTable.ScrollIntoView(this.topMostVisibleRowContext, this.ganttControl.GanttTable.Columns[0]);

            }

        }


This will ensure that the prev top-most visible row is currently visible - but it doesn't make it the top row.


So, this doesn't fully implement the original requirement - only partly.



� RadiantQ 2009 - 2019. All Rights Reserved.