C# 如何在带有4个标签的xamarin中使用2行2列将网格居中

C# 如何在带有4个标签的xamarin中使用2行2列将网格居中,c#,ios,visual-studio,xamarin,C#,Ios,Visual Studio,Xamarin,我有一个两列两行的网格。我在网格的开始和结尾有堆栈布局,在布局中有4个标签,分别是grid.Row[0]grid.Column[0]。。。等等 守则: <Frame CornerRadius="30" BackgroundColor="Transparent" Margin="20,0,20,10"

我有一个两列两行的网格。我在网格的开始和结尾有堆栈布局,在布局中有4个标签,分别是grid.Row[0]grid.Column[0]。。。等等

守则:

                <Frame CornerRadius="30"
                       BackgroundColor="Transparent"
                       Margin="20,0,20,10"
                       HeightRequest="100"
                       BorderColor="Red">
                  <StackLayout HorizontalOptions="FillAndExpand"
                                 VerticalOptions="FillAndExpand">
                       <Grid BackgroundColor="Transparent"
                              Padding="0,0,0,0">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                    <Label Text="Temp Now"
                                           VerticalOptions="Center"
                                           TextColor="White"
                                           VerticalTextAlignment="Center"
                                           FontAttributes="Bold" 
                                           FontSize="15"
                                           Grid.Row="0"
                                           Grid.Column="0"/>

                                    <Label x:Name="TempNowLbl"
                                           VerticalOptions="Center"
                                           TextColor="White"
                                           VerticalTextAlignment="Center"
                                           FontAttributes="Bold" 
                                           FontSize="25"
                                           Grid.Row="1"
                                           Grid.Column="0"/>
                                           
                                    <Label Text="Wind Speed"
                                           VerticalOptions="Center"
                                           TextColor="White"
                                           VerticalTextAlignment="Center"
                                           FontAttributes="Bold" 
                                           FontSize="15"
                                           Grid.Row="0"
                                           Grid.Column="1"/>

                                    <Label x:Name="WindSpeedNowLbl"
                                           VerticalOptions="Center"
                                           TextColor="White"
                                           VerticalTextAlignment="Center"
                                           FontAttributes="Bold" 
                                           FontSize="25"
                                           Grid.Row="1"
                                           Grid.Column="1"/>
                       </Grid>
                </StackLayout>
             </Frame>

结果是:


如何将标签居中?

使用
标签上的
水平文本对齐=“中心”

<Frame CornerRadius="30"
       BackgroundColor="Transparent"
       Margin="20,0,20,10"
       HeightRequest="100"
       BorderColor="Red">
       <Grid BackgroundColor="Transparent"
              Padding="0,0,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                    <Label Text="Temp Now"
                           VerticalOptions="Center"
                           TextColor="White"
                           VerticalTextAlignment="Center"
                           HorizontalTextAlignment="Center"
                           FontAttributes="Bold" 
                           FontSize="15"
                           Grid.Row="0"
                           Grid.Column="0"/>

                    <Label x:Name="TempNowLbl"
                           VerticalOptions="Center"
                           TextColor="White"
                           VerticalTextAlignment="Center"
                           HorizontalTextAlignment="Center"
                           FontAttributes="Bold" 
                           FontSize="25"
                           Grid.Row="1"
                           Grid.Column="0"/>
                           
                    <Label Text="Wind Speed"
                           VerticalOptions="Center"
                           TextColor="White"
                           VerticalTextAlignment="Center"
                           HorizontalTextAlignment="Center"
                           FontAttributes="Bold" 
                           FontSize="15"
                           Grid.Row="0"
                           Grid.Column="1"/>

                    <Label x:Name="WindSpeedNowLbl"
                           VerticalOptions="Center"
                           TextColor="White"
                           VerticalTextAlignment="Center"
                           HorizontalTextAlignment="Center"
                           FontAttributes="Bold" 
                           FontSize="25"
                           Grid.Row="1"
                           Grid.Column="1"/>
       </Grid>
</Frame>