R – Silverlight Listbox Performance issue with ListBox

listboxperformancesilverlight

I'm developing a Silverlight application that displays items in a listbox control and I've run into a bit of a performance issue.

Each item in the listbox is a custom stackpanel with some formatted text and such.

When I've got a list of 500 or less items the listbox works fine, but loading more than this causes problems. At 1000 items, Silverlight will consume 10% cpu, even if I'm not doing anything, at 3000 items the cpu constantly uses 32-36%.

This is on a dual core machine, on an older machine I tested out on the cpu usage goes way up.

This also effects the framerate, I'm getting 6fps with a 3000 item listbox, which makes the application sluggish.

Does anyone know what might be causing this? My first thought was that silverlight is trying to render all the items, even though the items are off screen… this seems to be consistant as if I insert items with their Visability.Collapsed, the extra cpu overhead is not present.

PS: I'm running in windowless="true" as I need to display some html ontop of my silverlight form.

Best Answer

You should use the DataGrid in Silverlight 2 because it supports UI Virtualization. It has been tested with millions of items and will only create enough visuals needed to display.

Related Topic