作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我知道您可以通过这种方式在 XAML 中使用“*”设置行高:
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
但在 C# 中相同的表达式返回错误:
new RowDefinition { Height = new GridLength("*", GridUnitType.Auto) },
所以我的问题是如何在 C# 中将网格的行高设置为“*”?
最佳答案
var grid = new Grid ();
grid.RowDefinitions.Add (new RowDefinition { Height = GridLength.Auto });
grid.RowDefinitions.Add (new RowDefinition { Height = new GridLength (1, GridUnitType.Star) });
var stacklayout1 = new StackLayout { HeightRequest = 100, BackgroundColor = Color.Red };
var stacklayout2 = new StackLayout { BackgroundColor = Color.Blue };
Grid.SetRow (stacklayout2, 1);
grid.Children.Add (stacklayout1);
grid.Children.Add (stacklayout2);
MainPage = new ContentPage { Content = grid };
关于c# - Xamarin Forms Grid - C# 中的行高为 "*"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32005192/
我是一名优秀的程序员,十分优秀!