3
votes

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

2
are your strings binding or added in the xaml? - Joseph Le Brech
Sounds to me as you're testing on a emulator. What you're experiencing isn't a software technical problem, as as such we can't give you a answer. - Claus Jørgensen
I test on device(and FYI all performance related things should be tested on device) . U'd better tried to reproduce problem yourself before writing such conclusions. - Grigory

2 Answers

4
votes

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").

1
votes

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)