zoukankan      html  css  js  c++  java
  • Grid

      使用Grid,可以在行和列中排列控件。

      对于每一列,可以指定一个ColumnDefinition;对于每一行,可以指定一个RowDefinition。

      下面的示例代码显示两列和三行。

      在每一列和每一行中,都可以指定宽度或高度。

      ColumnDefinition有一个Width依赖属性,RowDefinition有一个Height依赖属性。

      可以以像素,厘米,英寸或点为单位定义高度和宽度,或者把它们设置为Auto,根据内容来确定其大小。

      Grid还允许根据具体情况指定大小,即根据可用的空间以及于其他行和列的相对位置,计算行和列的空间。

      在为列提供可用空间时,可以将Width属性设置为"*"。要使某一列的空间是另一列的两倍,应指定“2*”。下面的示例代码定义了两列和三行,但没有定义列定义和行定义的其他设置,默认使用根据具体情况指定大小的设置

      

    <Window x:Class="Panel布局.Grid"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Grid" Height="300" Width="300">
        <Grid ShowGridLines="True">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Label Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Center" Content="Title"/>
            <Label Grid.Column="0"  Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" Content="FirstName:"/>
            <TextBox Grid.Column="1"  Grid.Row="1" Width="100" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            <Label Grid.Column="0"  Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" Content="LastName:"/>
            <TextBox Grid.Column="1"  Grid.Row="2" Width="100" VerticalAlignment="Center" HorizontalAlignment="Center"/>
        </Grid>
    </Window>

  • 相关阅读:
    Sql Server字符串拆分(Split)方法汇总
    Raid0、Raid1、Raid0+1、Raid3和Raid5 几种磁盘阵列区别
    浅谈sql优化
    python 多进程和异步io的有机结合 Error in atexit._run_exitfuncs
    asp.net.core学习笔记1:swagger的使用和webapi接收Jobject对象
    在windows服务中托管asp.net.core
    人脸识别:face_recognition初尝试
    python 快速搭建局域网文件服务器 SimpleHTTPServer http.server
    sso和oauth2.0的简单了解学习
    python常用删除库的方法
  • 原文地址:https://www.cnblogs.com/hdsong/p/5076411.html
Copyright © 2011-2022 走看看