I have the following source code for setting up a Xamarin.Forms.Grid
control on my page. I will like the first 3 rows to expand both columns. The code sample in the online documentation does not really explain how this works.
Here is the source code:
Grid myGrid = new Grid();
myGrid.HorizontalOptions = LayoutOptions.FillAndExpand;
myGrid.RowDefinitions = new RowDefinitionCollection
{
new RowDefinition { Height = new GridLength(50, GridUnitType.Absolute) },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = new GridLength(30, GridUnitType.Absolute) }
};
myGrid.ColumnDefinitions = new ColumnDefinitionCollection
{
new ColumnDefinition { Width = GridLength.Auto },
new ColumnDefinition { Width = new GridLength(30, GridUnitType.Absolute) }
};
//I need Rows 1,2,3 to span two columns
myGrid.Children.Add(new Label { Text = "Row 1" }, 0, 0);
myGrid.Children.Add(new Label { Text = "Row 2" }, 0, 1);
myGrid.Children.Add(new Label { Text = "Row 3" }, 0, 2);
myGrid.Children.Add(new Label { Text = "Row 4, column 1" }, 0, 3);
myGrid.Children.Add(new Label { Text = "Row 4, column 2" }, 1, 3);
How do I modify the code to have the first 3 rows span 2 columns?