title: Silverlight performance with many loaded controls
body: <p>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). </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Do you have any idea how to solve this problem? 
  <strong>Why more opened controls slow down other controls?</strong></p>
  
  <p>I have created a sample that shows this issue: <a href="http://cenud.cz/PerfTest.zip">VS solution</a>, <a href="http://cenud.cz/PerfTestTestPage.html">live demo</a></p>
  
  <p>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, <strong>why is it slower as more controls are loaded elsewhere?</strong> Is there a way to improve the performance?</p>
  
  <p>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.</p>