Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight performance with many loaded controls

I have a SL application with many DataGrids (from Silverlight Toolkit), each on its own view. If several DataGrids are opened, changing between views (TabItems, for example) takes a long time (few seconds) and it freezes the whole application (UI thread).

The more DataGrids are loaded, the longer the change takes. These DataGrids that slow the UI chanage might be on other places in the app and not even visible at that moment. But once they are opened (and loaded with data), they slow showing other DataGrids. Note that DataGrids are NOT disposed and then recreated again, they still remain in memory, only their parent control is being hidden and visible again.

I have profiled the application. It shows that agcore.dll's SetValue function is the bottleneck. Unfortunately, debug symbols are not available for this Silverlight native library responsible for drawing.

The problem is not in the DataGrid control - I tried to replace it with XCeed's grid and the performance when changing views is even worse.

Do you have any idea how to solve this problem? Why more opened controls slow down other controls?

I have created a sample that shows this issue: VS solution, live demo

UPDATE: Using VS11 profiler on the sample provided suggests that the problem could be in MeasureOverride being called many times (for each DataGridCell, I guess). But still, why is it slower as more controls are loaded elsewhere? Is there a way to improve the performance?

UPDATE 2: I should mention that I don't use TabControl in my particular application. I use Caliburn.Micro and ContentControl to show currently active ViewModel. But the same issue is with TabControl so I used it to describe the core problem.

like image 671
gius Avatar asked Mar 18 '12 13:03

gius


1 Answers

So, I followed the idea of creating custom control and here is the result: http://www.baud.cz/blog/fast-switching-between-viewmodels-in-caliburn.micro.

Quick links to MVVM demo applications: Original and Fixed

like image 200
gius Avatar answered Oct 01 '22 19:10

gius