xmarin-xmarin.forms中的Grid使用

<StackLayout>
            <!--行设的是高度,列设的是宽度-->
            <Grid RowDefinitions="25,*,Auto" ColumnDefinitions="Auto,Auto,Auto">
                <Label Grid.Row="0" Grid.Column="0" Text="0,0" TextColor="Red" HorizontalTextAlignment="Center" BackgroundColor="Yellow" />
                <Label Grid.Row="0" Grid.Column="1" Text="0,1" TextColor="Red" HorizontalOptions="Center" BackgroundColor="Purple"/>
                <Label Grid.Row="0" Grid.Column="2" Text="0,2" TextColor="Red" BackgroundColor="Bisque"/>
                <Label Grid.Row="1" Grid.Column="0" Text="第二行第1列" TextColor="Blue"/>
                <Label Grid.Row="1" Grid.Column="1" Text="第二行第2列" TextColor="Blue" />
                <Label Grid.Row="1" Grid.Column="2" Text="第二行第3列" TextColor="Blue"/>
                <Label Grid.Row="2" Grid.Column="0" Text="2,0" TextColor="Green"/>
                <Label Grid.Row="2" Grid.Column="1" Text="2,1" TextColor="Green"/>
                <Label Grid.Row="2" Grid.Column="2" Text="2,2" TextColor="Green"/>
            </Grid>
            
            <!--Margin默认语法(左,上,右,下)-->
            <Grid RowDefinitions="25,*,Auto" ColumnDefinitions="*,*,*" Margin="0,100">
                <Label Grid.Row="0" Grid.Column="0" Text="居中且块有背景" TextColor="Red" HorizontalTextAlignment="Center" BackgroundColor="Yellow" />
                <Label Grid.Row="0" Grid.Column="1" Text="字体有背景" TextColor="Red" HorizontalOptions="Center" BackgroundColor="Purple"/>
                <Label Grid.Row="0" Grid.Column="2" Text="默认居左显示" TextColor="Red" BackgroundColor="Bisque"/>
                <Label Grid.Row="1" Grid.Column="0" Text="第二行第1列" TextColor="Blue"/>
                <Label Grid.Row="1" Grid.Column="1" Text="第二行第2列" TextColor="Blue" />
                <Label Grid.Row="1" Grid.Column="2" Text="第二行第3列" TextColor="Blue"/>
                <Label Grid.Row="2" Grid.Column="0" Text="2,0" TextColor="Green"/>
                <Label Grid.Row="2" Grid.Column="1" Text="2,1" TextColor="Green"/>
                <Label Grid.Row="2" Grid.Column="2" Text="2,2" TextColor="Green"/>
            </Grid>
            <Label Text="当前组织机构"/>
            <Entry Text="{Binding DataOrgName}" />
        </StackLayout>
View Code

原文地址:https://www.cnblogs.com/lishidefengchen/p/14569167.html