Fixing jumpy ListBox scrolling in WP7 Mango

Update October 14, 2011: If you are using Buttons in your item templates this may cause some issues. See the comments at the bottom of the page for more information and a potential workaround.

A few days ago I tweeted about a ListBox scrolling issue I found with WP7 Mango when using item templates that have different heights. I first noticed this issue when using the Silverlight Toolkit’s LongListSelector control, but I found that it also applies to the standard ListBox control (which the Mango version of the Silverlight Toolkit uses internally to display data) whenever list items have different heights (e.g., wrapped text, list headers/footers, etc.).

In short, the issue is that after tapping/selecting an item in the list, scrolling becomes extremely jumpy. It’s a bit hard to describe — it’s not just a matter of poor performance, the list scroll position will actually jump up or down as you try to scroll through the list.

I found a relevant bug report on the SL Toolkit’s issue tracker here. At first I thought the issue was caused by selecting an item within the ListBox but I found that deselecting the item didn’t fix the scrolling behavior.

After doing some further testing I discovered that the issue was triggered whenever the ListBox (or a control displayed within the ListBox) gained focus. Setting focus to another control on the page seems to fix the issue completely.
Continue reading Fixing jumpy ListBox scrolling in WP7 Mango