Debugging Layout cycle detected. Layout could not complete. RRS feed

  • Question

  • Since I have moved my images into a canvas to work around this bug: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/a0aad9ae-4163-41ec-96bb-3a84412476e3 in one particular situation in my application I get this exception: "Layout cycle detected.  Layout could not complete.".  Turns out, it is due to using a progress bar:

    <ProgressBar Minimum="0" Maximum="100" Value="{Binding DownloadableImage.PercentDownloaded}" Margin="0,5,0,5" Width="100" Foreground="{StaticResource BorderHoverBrush}"/>

    If the progress bar is commented out, everything works fine.  This page displays other content fine, it's just this particular piece of content that it has a problem with, and I have no idea why.  Why would a progress bar cause this sort of a problem?  How can I fix it?


    Thursday, July 5, 2012 1:29 AM

All replies

  • Does the app you sent repro this problem?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Thursday, July 5, 2012 8:08 PM
  • Hi Stefan,

    Layout cycle errors occur generally when Layout of a control is updated in an infinite loop. So, in above usage if you are re-starting the progress before the previous can complete, then it might end-up in a loop causing the exception. Also, if you have the "Value" property set to a literal - say 40 , then do you still see the exception?

    Thursday, July 5, 2012 8:39 PM
  • Matt,

    Have e-mailed you details of where you can look at the app.


    Thursday, July 5, 2012 8:52 PM
  • @Sagar,

    Thanks for the suggestion. Unfortunately I do still see the exception with the value property set to 40


    Thursday, July 5, 2012 8:53 PM
  • You didn't send me the project, so I'm not sure what I'm seeing here.  The application seems to work - am I missing something?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    Friday, July 6, 2012 8:37 PM
  • Matt,

    Have e-mailed you some more details.  Please let me know if you need any further information.


    Friday, July 6, 2012 9:40 PM
  • I can repro this problem with only a few minor modifications to the default Grid app template.

    1. Modify SampleDatasource.cs to include 140 items in the first group.
    2. In GroupedItemsPage.xaml, change CollectionViewSource so ItemsPath="Items" (instead of "TopItems")
    3. In GroupedItemsPage.xaml, make a copy of the Standard250x250ItemTemplate Xaml.
    4. In the new Standard250x250ItemTemplate Xaml, toss a <ProgressBar/> anywhere.

    Let me know if you'd like a sample app with these steps above to more easily demonstrate the issue. This definitely seems like a bug.

    Also, this may have been introduced in a recent update to Windows. It seems like these errors only started showing up in my app a few months ago.


    Thursday, August 1, 2013 10:04 PM
  • fyi: The only way I found to work around this was to create my own determinate ProgressBar control (pretty easy to do since it's just 2 rectangles). Seems like a bug in ProgressBar.
    Friday, August 2, 2013 8:51 PM
  • Tim,

    Yes, it does seem like a bug and it looks like it hasn't been fixed on windows 8.1.  Hopefully you can post your sample app and someone from Microsoft can actually get this fixed before 8.1 ships.

    Your workaround suggestion is a good one I may have to do that in the meantime. Thanks.


    Friday, August 2, 2013 10:29 PM
  • Friday, August 2, 2013 10:30 PM
  • fyi: I just posted my repro on the other thread.
    Friday, August 2, 2013 10:41 PM