我有以下网格,它被加载到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
}
};
我已经改变了网格的宽度值和宽度类型,但我不能让它填满整个屏幕,除非我使用固定值,这在我的手机上看起来很好,但在其他一切上真的很糟糕
答案 0 :(得分:7)
尝试将VerticalOptions = LayoutOptions.FillAndExpand
添加到父StackLayout
答案 1 :(得分:0)
对于我来说,我必须将VerticalOptions = FillAndExpand
添加到父StackLayout
并将祖父母Frame
设置为Padding = 0