Get updated VerticalOffset of ScrollViewer after ChangeView()
While trying to scroll to the bottom of ListView using ListView's ScrollViewer like:
ScrollViewer.ChangeView(null, ScrollViewer.ScrollableHeight, null);
Due to virtualization, the bottom gets rendered on the scroll and bottom is pushed further more so there is some more left to scroll. I tried replacing ScrollableHeight with ExtentHeight like:
ScrollViewer.ChangeView(null, ScrollViewer.ExtentHeight , null);
Still it doesn't help.
So I tried to check if the ScrollViewer.VerticalOffset has reached the expected height, else again I am performing the ChangeView(). Here is the code:
while(ScrollViewer.VerticalOffset != ScrollViewer.ScrollableHeight)
{
ScrollViewer.ChangeView(null, ScrollViewer.ScrollableHeight, null);
ScrollViewer.UpdateLayout();
}
Here the problem is the ScrollViewer.VerticalOffset isn't updated by the change view. Tried UpdateLayout too but still doesn't work.
Is there any way to refresh the value of ScrollViewer.VerticalOffset after scroll?
Update:
Sample ListView code
<ListView x:Name="PicturesLV"
ItemsSource="{x:Bind PicturesCollection, Mode=OneWay}"
HorizontalAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate x:DataType="model:PicturesBObj">
<local:PicturesListViewItemControl PictureInstance="{x:Bind}"/>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer>
<TextBlock x:Name="BottomMostPartTb" Text="Bottom"/>
</ListView.Footer>
</ListView>
I used this PicturesLV.ScrollIntoView(PicturesLV.Footer)
to scroll to the bottom. Since the pictures get rendered after scroll to bottom, the BottomMostPartTb gets pushed further below
Is there any way to hold the scrolled position irrespective of rendering and virutalization?