Skip to content

(Marquee) When Behavior="Looping" and Direction is set to vertical, it causes “Layout cycle detected. Layout could not complete.” #755

@lgztx96

Description

@lgztx96

Describe the bug

<Setter Property="VerticalAlignment" Value="Top" />

private void Container_SizeChanged(object sender, SizeChangedEventArgs e)

_segment2.Visibility = IsLooping ? Visibility.Visible : Visibility.Collapsed;

_segment2.Visibility = Visibility.Collapsed;

I noticed that the Marquee control crashes. After debugging, I believe the SizeChanged event causes the visibility of segment2 to change. Since the control’s default vertical alignment is set to Top, this triggers another SizeChanged event, resulting in an infinite loop.
Setting VerticalAlignment="Stretch" allows it to work correctly, but this is not a real solution.

In addition, I noticed that _marqueeContainer is repeatedly subscribing to the SizeChanged event.

_marqueeContainer.SizeChanged += Container_SizeChanged;

_marqueeContainer.SizeChanged += Container_SizeChanged;

Steps to reproduce

<labs:Marquee
     Behavior="Looping"
     Content="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
     Direction="Down"
     FontSize="18"
     RepeatBehavior="Forever"
     Speed="200" />


Just setting Behavior="Looping" is enough to trigger the crash.

Expected behavior

This shouldn't cause the program to crash.

Screenshots

Image

Code Platform

  • UWP
  • WinAppSDK / WinUI 3
  • Web Assembly (WASM)
  • Android
  • iOS
  • MacOS
  • Linux / GTK

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Other (specify)

Other SDK version

No response

Visual Studio Version

No response

Visual Studio Build Number

No response

Device form factor

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions