Silverlight for Windows Phone 7: ListBox Scroll Performance


Having a basic list scoll is a key scenario for many applications. The Silverlight Windows Phone 7 list box control makes it easy to bind data and get the performance benefits of UI container virtualization. However, in order to get these free performance benefits you need to be careful about how you use it.

Here are some tips on how to tweek your list box scroll performance published by the Silverlight Windows Phone 7 Perfomance Team.

  • Simplify ListBox Item
  • Listbox’s VirtualizingStackPanel (VSP), calculates the height of items currently in the view and buffers the UI containers for a screens worth of items above and below what is currently in the view. This works great if the items are of fixed size. If you change the size of the items, the UI virtualization breaks and you don’t get any performance benefits.

    • Ensure you have the item data template in a fixed sized container (grid).
    • Avoid/remove using complex converters, when the same information can be easily provided by the data object.
    • Avoid/remove nested structures, example listbox in a listbox item.
    • Strongly recommended to not use user control inside the data template.
    • Avoid/remove custom controls from the data template
  • Load the images in background
    • If you have refered to the performance document, you will know the importance of keeping the UI thread free for better responsiveness to handle input. This means that if you load the images on the UI thread, an input like flick might be lost. David talks about how to move the image loading to a single background thread in his blog LowProfileImageLoader.
  • Use Data Virtualization
  • Do not use ListBox
  • Do not use Nested ListBox
  • Other tips/approaches
  • For a details goto: http://blogs.msdn.com/b/slmperf/archive/2010/10/06/silverlight-for-windows-phone-7-listbox-scroll-performance.aspx
    Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s