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

listView ViewCell not adjusting it's size to content on iOS

$
0
0

I have a custom ViewCell that i use to populate a listView. It works like a charm on android, on iOS however i'm having issues.

The cell has a Horizontal stackLayout with a box and a 2nd stackLayout, the 2nd Stacklayout is vertical and has 2 labels.
On iOS if the labels has multiple rows of content the text overlaps the cell below. On Android it works just fine.

This is my code, what am i doing wrong?

public class NewsCell : ViewCell
    {
        public NewsCell ()
        {
            var headerLabel = new Label();
            var contentLabel = new Label();

            headerLabel.SetBinding(Label.TextProperty, "header");
            contentLabel.SetBinding(Label.TextProperty, "content");

            this.View = new StackLayout {
                Padding = new Thickness (0, 5),
                Orientation = StackOrientation.Horizontal,
                Children = {
                    new BoxView {
                        Color = Color.Accent,
                        WidthRequest = 50,
                        HeightRequest = 50
                    },
                    new StackLayout {
                        Spacing = 0,
                        Children = {
                            headerLabel,
                            contentLabel
                        }
                    }
                }

            };
        }
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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