2017-07-24 64 views
0

我有一個網格,我希望它填滿屏幕。 例如,我可以使用水平選項嗎?如何使用xaml - xamarin.forms填充屏幕布局?

<Grid> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition Height="Auto"/> 
      <RowDefinition Height="Auto"/> 
     </Grid.RowDefinitions> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto"/> 
      <ColumnDefinition Width="Auto"/> 
      <ColumnDefinition Width="Auto"/> 
     </Grid.ColumnDefinitions> 

     <Button Image="imgteste.png" Grid.Row="0" Grid.Column="0"></Button> 
     <Label Text="User name:" Grid.Row="0" Grid.Column="1"></Label> 
     <Label Text="User name:" Grid.Row="1" Grid.Column="0"></Label> 
     <Label Text="User name:" Grid.Row="1" Grid.Column="1"></Label> 
    </Grid> 

回答

1

您需要添加HorizontalOptionsVerticalOptions像你這樣想。

<Grid HorizontalOptions="Fill" 
     VerticalOptions="Fill"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto"/> 
     <ColumnDefinition Width="Auto"/> 
     <ColumnDefinition Width="Auto"/> 
    </Grid.ColumnDefinitions> 

    <Button Image="imgteste.png" Grid.Row="0" Grid.Column="0"></Button> 
    <Label Text="User name:" Grid.Row="0" Grid.Column="1"></Label> 
    <Label Text="User name:" Grid.Row="1" Grid.Column="0"></Label> 
    <Label Text="User name:" Grid.Row="1" Grid.Column="1"></Label> 
</Grid> 
+0

非常感謝你 –

相關問題