Grigory
Grigory

Reputation: 1922

Windows Phone Mango listbox scrolling

I created a simple application with ListBox and 1000 very short strings in it. (no explicit ItemTemplate). If i scroll it really fast - there are black holes(CPU cant render fast i suppose).

At the same time if i use ItemsControl in ScrollViewer - everything is OKay.

Why ? Can i slow down scrolling speed in ListBox somehow ? Users can get really confused when they are to see these black holes in the screen.

Update: Reproduces on device(HTC HD7 7.10.7740). I use databinding via ItemSource

Repro project: https://www.dropbox.com/s/lgcod878srnctp0/SLTK_LLS_TEST.zip

Repro video(!): https://www.dropbox.com/s/t25dguq0vaa88o9/WP_20111213_113729Z.mp4

Upvotes: 3

Views: 1341

Answers (2)

thmshd
thmshd

Reputation: 5847

The ListBox has "virtualization" enabled by default (exactly: sort of UI container virtualization), it's not loading the complete list, just fragments. When scrolling, it has to render the items first, and when you scroll quickly, you are noticing this rendering delay. It's achieved by the VirtualizingStackPanel. The advantage is, it saves Memory.

You can disable the virtualization when using a custom ItemsPanel:

<ListBox x:Name="YourListbox">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
</ListBox>

...but the solution will take up more resources from the beginning. Might become dangerous with long lists.

The other way round, you can enable virtualization on your ItemsControl, for a testing purpose, you should be able to achieve the rendering delay ("black holes").

Upvotes: 4

ZombieSheep
ZombieSheep

Reputation: 29953

How long are your strings? Is it something you can easily and sensibly split into a very brief summary (8 - 10 characters)? If so you might want to take a look at the LazyListBox which tries to address the issue (it was intended for more complex layouts than you are talking about, though, so the benefits may be negligible)

Upvotes: 1

Related Questions