I have a settings screen that is made of a grid that alternates between a header row that spans 2 columns and a 2nd row with a description of the setting and the control for that setting, usually a switch. The 2nd row is tall enough to accommodate the switch, but cuts off the text of the Label. I'm assuming I'm missing something in setting up the labels. Here is some sample code:
``
Label lblHeader1 = GetTitleLabel("Header 1");
Label lblText1 = GetTextLabel("Really long text");
chk1 = new Switch(); chk1.IsToggled = true; chk1.Toggled += chk_Toggled; Label lblHeader2 = GetTitleLabel("Header 2"); Label lblText2 = GetTextLabel("Also really long text."); chk2 = new Switch(); chk2.IsToggled = false; chk2.Toggled += chk_Toggled; Grid grid = new Grid() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition{Height = new GridLength(1, GridUnitType.Auto)}, new RowDefinition{Height = new GridLength(1, GridUnitType.Auto)} }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) } } }; grid.Children.Add(lblHeader1, 0, 2, 0, 1); grid.Children.Add(lblText1, 0, 1); grid.Children.Add(chk1, 1, 1); grid.Children.Add(lblHeader2, 0, 2, 2, 3); grid.Children.Add(lblText2, 0, 3); grid.Children.Add(chk2, 1, 3);
``
Here are the helper methods that generate the Labels
``
private Label GetTitleLabel(string text)
{
Label titleLabel = new Label();
titleLabel.Text = text;
titleLabel.Font = Font.SystemFontOfSize(20);
titleLabel.TextColor = Color.FromHex("#000FDE");
titleLabel.LineBreakMode = LineBreakMode.WordWrap;
titleLabel.HorizontalOptions = LayoutOptions.StartAndExpand;
return titleLabel; } private Label GetTextLabel(string text) { Label titleLabel = new Label(); titleLabel.Text = text; titleLabel.Font = Font.SystemFontOfSize(14); titleLabel.TextColor = Color.Black; titleLabel.LineBreakMode = LineBreakMode.WordWrap; titleLabel.HorizontalOptions = LayoutOptions.StartAndExpand; return titleLabel; }
`