xamarin/Xamarin.Forms

[Bug] Label Truncation inconsistent between StackLayout and Grid

Open

#6,246 opened on May 21, 2019

 (3 comments) (0 reactions) (0 assignees)C# (1,926 forks)batch import
a/layoute/6 :clock6:help wantedi/lowt/bug :bug:up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

I have two labels in a horizontal StackLayout. The second is set to TailTruncation as it is sometimes a long string. This was causing the first to wrap onto two lines. So I then set the LineBreakMode="NoWrap" for that one and the second control is still overlapping the first control as if it was wrapping the text. How do I stop this from happening? I want the first control to show the entire label.

I implemented the two controls in a Grid and it acts as expected. Since I have a workaround it is not blocking, but the two layouts should be consistent

Steps to Reproduce

  1. Here's the code
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height = "Auto" />
    </ Grid.RowDefinitions >
    < Grid.ColumnDefinitions >
        < ColumnDefinition Width="Auto" />
        <ColumnDefinition Width = "Auto" />
    </ Grid.ColumnDefinitions >
    < Label Grid.Column="0" Text="APPLICATION" FontSize="Small" FontAttributes="Bold" TextColor="Gray"
                                LineBreakMode="NoWrap" HorizontalOptions="StartAndExpand"/>
    <Label Grid.Column="1" Text= "Super long string that should be truncated, but somehow fit on the screen." HorizontalTextAlignment= "End"
                                FontSize= "Small" HorizontalOptions= "End" FontAttributes= "None" TextColor= "Gray"
                                LineBreakMode= "TailTruncation" />
</ Grid >
< StackLayout Orientation= "Horizontal" >
    < Label Text= "APPLICATION" FontSize= "Small" FontAttributes= "Bold" TextColor= "Gray"
                                LineBreakMode= "NoWrap" HorizontalOptions= "StartAndExpand" />
    < Label Text= "Super long string that should be truncated, but somehow fit on the screen." HorizontalTextAlignment= "End"
                                FontSize= "Small" HorizontalOptions= "End" FontAttributes= "None" TextColor= "Gray"
                                LineBreakMode= "TailTruncation" />
</ StackLayout >

Expected Behavior

Stack should layout the same as the Grid

Actual Behavior

First control in the Stack gets clipped.

Basic Information

  • Version with issue: 3.6.0.264807
  • Last known good version: ??
  • IDE: Visual Studio 2019
  • Platform Target Frameworks:
    • iOS: 12.2
    • Android: 8.1
    • UWP: N/A
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices: iOS and Andriod

Screenshots

image

Reproduction Link

Contributor guide