Ale*_*akh 4 grid xamarin xamarin.forms
我设法从代码中设置行和列,但无法将此设置移动到xaml:
grid.RowDefinitions = new RowDefinitionCollection {
new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }
};
grid.ColumnDefinitions = new ColumnDefinitionCollection {
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
};
Run Code Online (Sandbox Code Playgroud)
以下不起作用:
<Grid x:Name="grid" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
...
</Grid>
Run Code Online (Sandbox Code Playgroud)
从文档中我设法只获取c#实现
对于具有单个单元格的网格(1行/列,我也得到相同的行为(不填充和扩展),虽然我不确定为什么我们需要一个单个单元格全尺寸屏幕的网格),但它似乎适用于2 x 2,3 x 3单元网格(还没有尝试过其他网格).
Xamarin Forms中需要Height =" "和Width =" "属性,尽管我认为在WPF中不需要它们,因为默认情况下假设是这种情况.
<ContentPage.Content>
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" Text="1"></Button>
<Button Grid.Row="1" Grid.Column="1" Text="2"></Button>
</Grid>
</ContentPage.Content>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23136 次 |
| 最近记录: |