maui
maui copied to clipboard
Label WordWrap does not work inside HorziontalStackLayout or StackLayout with horizontal orientation
Description
A Label with LineBreakMode="WordWrap" does not wrap the text when inside a HorizontalStackLayout or StackLayout with Orientation="Horizontal". It works with a VerticalStackLayout.
Steps to Reproduce
- Put a Label inside a HorizontalStackLayout
- Set LineBreakMode to "WordWrap" and give it a long text
- Label doesnt break its text
Link to public reproduction project repository
https://github.com/borrmann/LabelBreak
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS, Windows
Affected platform versions
iOS 16, Windows 10.0.171340.0
Did you find any workaround?
no
Relevant log output
No response
Similar or the same as https://github.com/dotnet/maui/issues/10046
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Having the same issue, no workaround available. Breaking most of the layouts in our app. Please let us know when there is a workaround or a fix.
@jsuarezruiz when might this get picked up? It is disheartening to see so many layout issues not being resolved in a timely manner.
This is expected behavior; horizontal stack layouts do not limit the horizontal space their child controls can consume, so there's no reason for a Label to ever wrap its text.
If you need text to wrap, then you need to use a control which limits the horizontal space (like a Grid) or set a maximum width request on your horizontal layout.
@hartez gotcha! However, shouldn't the Width of the HorizontalStackLayout be limited to the Width of its parent, e.g. if we have the HorizontalStackLayout inside a Grid like you suggested?
@hartez gotcha! However, shouldn't the Width of the HorizontalStackLayout be limited to the Width of its parent, e.g. if we have the HorizontalStackLayout inside a Grid like you suggested?
No. Stacking layouts just keep stacking in their unconstrained direction until they run out of things to stack.
Not sure if this helps, but I had the same issue with word wrap not working. This was in a Grid cell, where the column definition width was set to "Auto". Changing to "*" it then wrapped without using LineBreakMode="WordWrap". Also I am using TextType="Html"