Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retain Listview scroll on page navigation

How can I maintain the listview scroll position if I navigate away to another page and come back by pressing back button?

It always resets it to top. Its a real pain to go back to the poition I was. Please help

like image 498
Milan Aggarwal Avatar asked Jan 04 '13 13:01

Milan Aggarwal


2 Answers

Alternatively you can add NavigationCacheMode="Enabled" in your Page XAML:

<Page 
NavigationCacheMode="Enabled">
like image 153
David Douglas Avatar answered Oct 04 '22 07:10

David Douglas


Mostly Step 1 will do the trick, If not you have to make changes in your listView by following step 2

1) this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled;

2)

<ListView.ItemsPanel>
    <ItemsPanelTemplate>
        <StackPanel Orientation="Vertical"/>
    </ItemsPanelTemplate>
</ListView.ItemsPanel>

I hope it helps :)

like image 35
Milan Aggarwal Avatar answered Oct 04 '22 06:10

Milan Aggarwal