Listbox jumps to top when resuming scroll from last position

c#, listbox, windows-phone-8.1

Solution

I had the same problem and figured out that it's primarily the chosen ItemsPanelTemplate which causes the Bug.

When using a ListView, the standard ItemsPanelTemplate is ItemsStackPanel, which works fine. If you change that to VirtualizingStackPanel (standard for ListBox) the bug appears. But only on Windows Phone, for Windows it works like expected.

So I assume that, when you like to use ListBox instead of ListView, you have to use ItemStackPanel as ItemsPanelTemplate to preserve the scroll position via NavigationCacheMode.

Problem

(Windows Phone 8.1) In my app, I have a MainPage with a listbox. NavigationCacheMode is set to required to preserve the state when navigating back to the same page. ``` public MainPage() { this.InitializeComponent(); this.DataContext = this; // cache page this.NavigationCacheMode = NavigationCacheMode.Required; } ``` So when I go to another page and come back to my MainPage everthing looks the same as I left it. The Listbox is also in the corrent position. But whenever I touch it, it will jump to the top before it scrolls... How can I make it so that it resumes scrolling before going to the top first? EDIT: solved Seems like Listbox is bugged in WP8.1, use ListView instead!

Original source