0

At a high level my application is applying about 5 different DataTemplates to a set of ListBoxItems based on their type. These items are laid out on a canvas at specific x, y points. I implemented virtualization on my ListBox and it did not seem to improve the time it takes to complete the rendering thread's processes. It still takes about 8-12 seconds for the UI to be completely loaded and usable by the user. I thought virtualization would help fix this problem but after looking around it looks like it only helps process scrolling large amounts of data. Am I correct in this assumption and does anyone else have any other tips for improving the rendering thread. This is the only problem I am having and then my project is complete. Thanks StackOverflow!

H.B.
  • 166,899
  • 29
  • 327
  • 400
jes9582
  • 253
  • 4
  • 15
  • 2
    Could you show the XAML? – Bas Sep 12 '11 at 12:59
  • I am not allowed to post any code, sorry. I will see if I can make it generic enough to put up here. It is a very large set of code, I know that does not help at all. – jes9582 Sep 12 '11 at 13:03
  • Is the problem only when running from VS. If you run the .exe direct do you still have the problem? It may have some binding errors you are not seeing. Try setting presentationtrace = high and run it once to see if you get any errors. – paparazzo Sep 12 '11 at 16:54

3 Answers3

1

Virtualisation means that only the items you have visible are created, then dynamically destroyed/new items created as you scroll. The alternative is all UI controls are created for all items at once.

It sounds like you have bigger problems with the rest of the app. Do you perform all loading operations on a background thread? Is the UI control tree very complex indeed? Are you displaying 100s or 1,000s of items?

Kieren Johnstone
  • 41,277
  • 16
  • 94
  • 144
1

We also had a lot of trouble with performance in WPF. Best way is of course to profile your application. We use ANTS Performance profiler for that, but any .NET profiler will do. We got a huge performance hit, because of the lookup of our XAML Resources. Thats the advice i can give you: Try to minimize all resources in XAML. But not only that, also try to minimize the amount of XAML files you have. One thing you can try is to defere the loading of complex parts of your DataTemplate. Similiar to what happens when you load a JPEG in a browser, first you will see a pixelated image which will be finer after it finished loading the JPEG. To accomplish that, use a simpler DataTemplate at first and then if this is visible only load the complex template on demand or after a while. But without more information of your specific problem, we can only guess. This is an old question of mine about a similiar subject, maybe this will help aswell.

Community
  • 1
  • 1
dowhilefor
  • 10,971
  • 3
  • 28
  • 45
0

Yes, ListBox virtualization is for scrolling. When you have a large number of items in a ListBox, enabling virtualization will make only the visible items (+ a few extra items for scrolling) render, and scrolling the ListBox replaces the data in the rendered items instead of rendering new items.

If you were to post some code, perhaps we could assist you with some performance tweaks

Rachel
  • 130,264
  • 66
  • 304
  • 490
  • I am going to post some generic code after my meetings. I am under strict policies for posting code sorry – jes9582 Sep 12 '11 at 13:32