Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open WPF window is slow due to layout affecting

I have a problem with wpf. The problem is my window, which uses some auto and * columns in a Grid, it is opening very slow. I've used the Visual Studio debugger to investigate what the trouble is, and found it in the layout section. The message is:

Changes were made to XAML visual tree that required the size and/or position of all affected elements to be computed.

Here is a screenshot of the debugger:

Debug Information

What is the best way to detect the exact problem with the layout? Or are there some general rules I could follow?

Thank you very much, I did not experience this behaviour with wpf before, even with large usercontrols / windows...

EDIT I don't use any animation of transformation to rotate controls. In general it is a very flat window. As an additional information, scrolling through GridViews in the window is also very slow.

like image 932
BendEg Avatar asked Oct 01 '15 13:10

BendEg


Video Answer


2 Answers

Off the top of my head (and re-iterating a few of the comments):

  • Are you using nested IsSharedSizeScope? This can cause cascading layout updates.
  • Have you turned off virtualization and have many items in the grid? This can cause slow and studdering performance.
  • Try to isolate the issue by removing stuff until it works (or removing a lot and adding things back until the issue starts to reappear)
  • Post your code here so we help you better
like image 165
Andreas Zita Avatar answered Oct 15 '22 12:10

Andreas Zita


I had the same issue. The reason was accidentally switched OFF virtualization in ListView in XAML file. Probably copy/paste from web. Changing from false to true made the magic.

VirtualizingPanel.IsVirtualizing="True" 
like image 42
Milan Švec Avatar answered Oct 15 '22 14:10

Milan Švec