views:

19

answers:

2

I have an application which contains a nested list box, that is a list box inside a listbox.itemtemplate in the item template of another list. I would like to prevent scrolling of the inner list box in favour of just scrolling the outer list box. At the moment either list can be scrolled which is a bit confusing for the user.

|-----------------------
|
| List Item 1
|    |---------------
|    |  Inner item 1
|    |  Inner item 2      <--scrolls and I don't want it to
|    |--------------
| List Item 2
A: 

I've never seen this implemented on a small screen device.

Put your "inner list" on a separate page.

This will avoid your problem and allow you to create an application with a behaviour which matches the behaviour of other applications the user may also have used, thereby making your application easier for your users. to use/understand

Matt Lacey
A: 

Hi Stimms,

I'm going to assume you know what you're doing here, but I'll offer a couple of things to consider regarding performance considerations as well.

Regarding solving your need to stop the inner listbox from scolling, you can use blend to retemplate the inner listbox and replace the ScrollViewer with a ContentPresenter. This will stop it scrolling.

Be careful with performance considerations with nested listboxes. Particularly you want to try and avoid having varying lengths of your inner listbox (your data may already cater for this).

Variable height listbox items at best will disrupt UI virtualisation which impedes scrolling performance.

At worst, there are still reports floating around of people experiencing problems with being able to scroll to the end of lists (a ctp issue thought to be resolved in beta, but is still surfacing for some people.)

You might also consider alternative implementations to simplify what you're displaying, or perhaps using a more light weight control for the inner container. StackPanel for example. Granted you may like listbox for it's ability to iterate over your data. You can assess your own performance. I recommend testing on a device as this can vary from the emulator.

Lastly, you might also like to check out the guidance here that was put together not too long ago.

Silverlight for Windows Phone 7: ListBox Scroll Performance

There's quite a few comments there on keeping listboxes not too complex for the sake of scrolling performance on devices.

Listbox scrolling is very nice when performing at it's best.

Mick N
I certainly never know what I'm doing. I might have 4 top level items and maybe a dozen items at most in each sublist. So well under 100 items total. Is that sort of data size still a performance worry? No images just text.
stimms
The general guidance is not to nest listboxes. If you're going to do it you'd want to be having a close look at your performance on a device to verify your performance matches that of a simple listbox. The fact that you have a variable number of inner list items is a loud warning bell for reasons described.
Mick N