黑马程序员_009布局的嵌套

来源:互联网 发布:ubuntu 查看gpu型号 编辑:程序博客网 时间:2024/06/08 10:03
---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------

布局的嵌套

一、效果图


二、描述

1、在名叫GridFather的Grid中插入三行三列,在第二行第二列中放置一个按钮

2、在名叫GridFather的Grid中的第一行第一列中嵌套一个名叫spChilren1的StackPanel,在里面放置三个按钮,按钮名字依次是1,2,3

3、在名叫GridFather的Grid中的第一行第三列中嵌套一个名叫gridChilren1的Grid,插入三行两列,在第一行第一列放置一个按钮。


二、源代码实现

控制界面的XAML代码:
<Window x:Class="jishuboke9.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        Title="MainWindow" Height="350" Width="525">    <Grid Name="GridFather">        <!--在GridFather中定义三行三列-->            <Grid.RowDefinitions>            <RowDefinition></RowDefinition>            <RowDefinition></RowDefinition>            <RowDefinition></RowDefinition>        </Grid.RowDefinitions>        <Grid.ColumnDefinitions>            <ColumnDefinition></ColumnDefinition>            <ColumnDefinition></ColumnDefinition>            <ColumnDefinition></ColumnDefinition>        </Grid.ColumnDefinitions>        <!--在GridFather中第二行第二列插入一个按钮-->        <Button Grid.Row="1" Grid.Column="1"/>        <!--在GridFather第一行第一列位置嵌套一个名叫spChilren的stackpanel,里面再加入三个按钮-->        <StackPanel Name="spChilren1" Grid.Row="0" Grid.Column="0">            <Button Content="1"/>            <Button Content="2"/>            <Button Content="3"/>        </StackPanel>        <!--在名叫gridFather的Grid中第一行第三列嵌套一个名叫GridChilren1的Grid,再分成三行两-->        <Grid Name="GridChilren1" Grid.Row="0" Grid.Column="2">            <Grid.RowDefinitions>                <RowDefinition/>                <RowDefinition/>                <RowDefinition/>            </Grid.RowDefinitions>            <Grid.ColumnDefinitions>                <ColumnDefinition/>                <ColumnDefinition/>            </Grid.ColumnDefinitions>            <Button/>        </Grid>                </Grid></Window>




---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------详细请查看:www.itheima.com
0 0