Silverlight Error “Layout Cycle Detected Layout could not complete”


Recently our Managing Director reported that while presenting the system froze with a white screen, or sometimes just the screen went un-responsive without no apparent error message on the screen.
Digging a bit deeper into it we found that there was a

“Layout Cycle Detected Layout could not complete”

that was being thrown.
Basically, in the page’ SizeChanged event, there was some code that was modifying the width of one of the panels on the page to accomodate to fit the content of the data field in the controls in the panel (which should ideally be done by setting width/height properties of the container elements to “Auto”), so causing the properties of the components to change while the layout was still being updated, ultimately resulting in this exception.

Once the containers were re-designed to Auto Size for the content (Also imposing a max width and max height with a Horizontal scrollbar to display content sensibly), the problem disappeared and away we went 🙂

Advertisements

About Jinish Bhardwaj
Jinish works as a Contractor @ Microsoft, Hyderabad and has more than 8 years of experience in building Web, Windows and Smart Client application for clients across the globe. Apart from that Jinish is also a Microsoft Certified Professional and a Certified SCRUM Master

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: