用 Grid 数据绑定

 Grid - 表格式布局模式
                Grid.RowDefinitions - 用于定义 Grid 中的行
                Grid.ColumnDefinitions - 用于定义 Grid 中的列
                Grid.ShowGridLines - 显示网格
        
                Grid.Row - 控件所在的 Grid 的行的索引
                Grid.Column - 控件所在的 Grid 的列的索引
                Grid.RowSpan - 合并行。 控件所在行,以及控件所在行之后的需要连续合并的行的总行数
                Grid.ColumnSpan - 合并列。 控件所在列,以及控件所在列之后的需要连续合并的列的总列数
        
                Width - 宽度
                MinWidth - 最小宽度
                MaxWidth - 最大宽度
                Height - 高度
                MinHeight - 最小高度
                MaxHeight - 最大高度

DEMO:

用来显示用户信息,XAML如下:

<Grid x:Name="LayoutRoot" Background="White" ShowGridLines="True">
                
                <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition Height="3*" />
                        <RowDefinition Height="7*" />
                        <RowDefinition Height="*" MinHeight="200" MaxHeight="500" />
                        <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                
                <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                </Grid.ColumnDefinitions>
                
                <TextBox Grid.Row="0" Grid.Column="0" Background="red" Text="abc" />
                <TextBox Grid.Row="0" Grid.Column="1" Background="red" Text="abc" Grid.ColumnSpan="2" HorizontalAlignment="Center" />
                <TextBox Grid.Row="1" Grid.Column="0" Background="red" Text="abc" />
                <TextBox Grid.Row="1" Grid.Column="1" Background="red" Text="abc" Grid.ColumnSpan="2" HorizontalAlignment="Center" />
                <TextBox Grid.Row="2" Grid.Column="0" Background="red" Text="abc" />
                <TextBox Grid.Row="2" Grid.Column="1" Background="red" Text="abc" Grid.RowSpan="2" VerticalAlignment="Bottom" />
                <TextBox Grid.Row="2" Grid.Column="2" Background="red" Text="abc" />
                <TextBox Grid.Row="3" Grid.Column="2" Background="red" Text="abc" />
                <TextBox Grid.Row="4" Grid.Column="2" Background="red" Text="abc" />
                
        </Grid> 
        

posted on 2011-06-07 10:44  张扬个性,敢为天下先  阅读(550)  评论(0编辑  收藏  举报