Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Bug in horizontal alignment in a custom ViewCell in the ListView

$
0
0

Hello,

I have a bug related with horizontal alignment in a custom ViewCell in the ListView. Or maybe I do something wrong.

I have a small and simple data model class:

public class DataItem
{
    public string CustomerAssetNo { get; set; }
    public string AccountName { get; set; }
    public DateTime LocalPlannedAt { get; set; }
}

And I have a list of these items in my MVVM page model (I use FreshMVVM, but it doesn't matter):

public List<DataItem> items = new List<DataItem>()
{
    new DataItem()
    {
        CustomerAssetNo = "Ovi-178502",
        AccountName = "SSAB Europe Oy",
        LocalPlannedAt = new DateTime(2014, 1, 10)
    },
    new DataItem()
    {
        CustomerAssetNo = "Kdi-531348",
        AccountName = "Konecranes Finland Oy / Hyvinkää Factory",
        LocalPlannedAt = new DateTime(2014, 1, 10)
    },
};

Finally I have a xaml page with this markup when I bind the items to the ListView and have a custom ViewCell:
`
<?xml version="1.0" encoding="utf-8" ?>


<ListView.ItemTemplate>

      <StackLayout Orientation="Horizontal">
        <Label Text="{Binding CustomerAssetNo}" LineBreakMode="NoWrap" />
        <Label Text="{Binding AccountName}" LineBreakMode="WordWrap" />
        <Label Text="{Binding LocalPlannedAt, StringFormat='{0:dd.MM.yyyy}'}" LineBreakMode="NoWrap" HorizontalOptions="EndAndExpand" />
      </StackLayout>

    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>


`
P.S. The code syntax id working ugly in this forum engine. But trust me there is a full normal xaml markup

And problem is there. The first row is shown correctly. But the second row is broken. The first and last labels text is cut, If a text in the middle label is too long. See the screenshot at Adnroid:
image

How can I fix it? I want to show all text in all labels. The text in the middle label have to wrapped more instead of the first and the last labels were draw apart.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>