Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
This repository was archived by the owner on May 1, 2024. It is now read-only.

[Bug] Word wrapped Label not measured correctly #8797

Closed
@JohnHDev

Description

@JohnHDev

Description

A Label in a grid that is contained in a StackLayout isn't measured correctly, with contents below the grid in the StackLayout overlapping the grid and label.

Steps to Reproduce

  1. Create a new template XF solution.
  2. Replace the MainPage xml with a new MainPage.cs
  3. Replace the code with the following and fix the namespace accordingly:
using System;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;

namespace LabelSizeTest
{
    public class MainPage : ContentPage
    {
        public MainPage()
        {
            On<iOS>().SetUseSafeArea(true);

            var grid = new Grid();
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star });
            grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            var label = new Label();
            label.LineBreakMode = LineBreakMode.WordWrap;
            label.Text = "This is a test teest test 2nd 3rd last";

            grid.Children.Add(label, 1, 0);

            var stack = new StackLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            stack.Children.Add(new BoxView()
            {
                BackgroundColor = Color.Blue,
                HeightRequest = 50
            });

            stack.Children.Add(grid);

            stack.Children.Add(new BoxView()
            {
                BackgroundColor = Color.Blue,
                HeightRequest = 50
            });

            Content = stack;
        }
    }
}
  1. Run on the iPhone 11 Simulator.

Expected Behavior

Label should display correctly, with all the text visible.

Actual Behavior

Label is being partially obscured by the 2nd BoxView, the words 3rd and Last are replaced with the BoxView.

Basic Information

  • Version with issue:

  • Last known good version:

  • IDE: VS4Mac

  • Platform Target Frameworks:

    • iOS:
  • Nuget Packages: XF 4.2.0

  • Affected Devices:

Screenshots

Simulator Screen Shot - iPhone 11 - 2019-12-08 at 11 15 31

Reproduction Link

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions