I have the following grid, which is loaded inside a StackLayout:
Grid grid = new Grid {
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
RowDefinitions =
{
new RowDefinition { Height = new GridLength(40, GridUnitType.Auto) },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = new GridLength(40, GridUnitType.Auto) },
},
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(100, GridUnitType.Auto) },
new ColumnDefinition { Width = new GridLength(100, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(50, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(50, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(100, GridUnitType.Auto) },
}
};
grid.Children.Add (btnMenu, 0, 1, 0, 1);
grid.Children.Add (lblProfile, 1, 5, 0, 1);
grid.Children.Add (btnEdit, 4, 5, 0, 1);
grid.Children.Add (lblFirstName, 1, 2, 1, 2);
grid.Children.Add (lblFirstNameValue, 2, 3, 1, 2);
Content = new StackLayout {
HorizontalOptions = LayoutOptions.StartAndExpand,
Children = {
grid
}
};
I have changed the width values and types of the width of the grid, but I can't make it to fill the whole screen, unless I use fixed values, which will look fine on my phone but really bad on everything else.
Try adding VerticalOptions = LayoutOptions.FillAndExpand
to the parent StackLayout
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With