WPF网格布局

1介绍:

Grid为WPF中最常用的布局容器, 它可以将一个区域分为若干个行或列功用其他组件使用。

2:网格标签Grid.ColumnDef

|------------------------|---------------------------------------------------------|
| Grid | 网格区域 |
| Grid.ColumnDefinitions | 自定义列 只能设置宽度 不能设置高度 |
| ColumnDefinition | 网格布局中列的区域(可以设置宽度,宽度可以是一个具体值 也可以设置*的意思, 把剩余的宽度按照比例进行平分) |
| Grid.RowDefinitions | 自定义行 可以设置高度 但是不能设置高度 |
| RowDefinition | 设置布局中行的区域(高度可以是一个具体值 也可以设置*的意思,把剩余的高度 按照比例进行平分) |

3:使用布局的属性

Grid.Row="1" 位置在第二行

Grid.Column = "0" 位置在第一列

实例:

cs 复制代码
<!--ShowGridLines 是否显示分割线-->
<Grid ShowGridLines ="True">
<!--网络标签-->
<!--一. Grid.ColumnDefinitions 自定义列 只能设置宽度 不能设置高度-->
        <Grid.ColumnDefinitions>
            <!--ColumnDefinition 每一个列可以设置宽度,宽度可以是一个具体指,也可以设置*,*的意思是将剩余的宽度按照比例进行平分-->
            <ColumnDefinition Width="200"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
<!--二. Grid.RowDefinitions自定义行 可以设置高度 不能设置宽度-->
        <Grid.RowDefinitions>
            <RowDefinition Height ="100"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

<!--三. 使用网格布局Grid.Row="1" Grid.Column="0"  第二行第一列-->
    <TextBlock Grid.Row="1" Grid.Column="0" Text="我是一个文本流"></TextBlock>
</Grid>
相关推荐
mldong12 小时前
给流程设计器加国际化,我没引 vue-i18n
前端·javascript·vue.js
IMPYLH12 小时前
HTML 的 <strong> 元素
前端·html
开开心心就好18 小时前
批量提取PDF中的图片,直接导出原图
前端·javascript·支持向量机·智能手机·pdf·html·启发式算法
Setsuna_F_Seiei20 小时前
前端转型 Agent 开发 05 之 Agent Hooks 与 Checkpointer(让 Agent 从全自动转变人为可掌控)
前端·agent·ai编程
百万蹄蹄向前冲1 天前
风扇转了一晚上MVP专家团翻车事故
前端·人工智能
默_笙1 天前
🏛 给 AI 配一间办公室:Harness Engineering 六大模块与它的实现
前端·javascript
淡海水1 天前
13-04-面试-源码级深度追问链
数据结构·unity·面试·c#·游戏引擎·源码·il2cpp
asdzx671 天前
如何使用 C# 提取 PPT 文本与图片
c#·ppt·提取文本
linux_cfan1 天前
videojs v10 源代码系列解读:14 · 谓词守卫:在运行时安全地调用能力
前端·javascript·音视频
kyriewen1 天前
我扒了 10,221 条 JD:腾讯技术岗 75% 在要 AI
前端·人工智能·ai编程