C#-WPF-布局-Grid

目录

大纲

常用属性与设置

实例

[实例1-布局Grid分3行3列(高度 宽度)](#实例1-布局Grid分3行3列(高度 宽度))

实例2-指定行列放置控件


实例

实例1-布局Grid分3行3列(高度 宽度)

html 复制代码
  <Grid ShowGridLines="True">
      
      <!--Grid添加-3列-->
      <Grid.ColumnDefinitions>
          <!--第1列-->
          <ColumnDefinition Width="1*"></ColumnDefinition>
          <!--第2列  2*是第1列2倍-->
          <ColumnDefinition Width="2*"></ColumnDefinition>
          <!--第3列  3*是第1列3倍-->
          <ColumnDefinition Width="3*"></ColumnDefinition>
      </Grid.ColumnDefinitions>

      <!--Grid添加-3行-->
      <Grid.RowDefinitions>
          
          <!--第1行-->
          <RowDefinition Height="30"></RowDefinition>
          <!--第2行    默认高度为占去剩余所有空间-->
          <RowDefinition></RowDefinition>
          <!--第3行-->
          <RowDefinition Height="30"></RowDefinition>
          
      </Grid.RowDefinitions>
      
  </Grid>

实例2-指定行列放置控件

html 复制代码
    <Grid ShowGridLines="True">
        
        <!--Grid添加-3列-->
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"></ColumnDefinition>
            <ColumnDefinition Width="2*"></ColumnDefinition>
            <ColumnDefinition Width="3*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <!--Grid添加-3行-->
        <Grid.RowDefinitions>
            <RowDefinition Height="80"></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="80"></RowDefinition>
        </Grid.RowDefinitions>

        <Button Width="100" Height="50" Grid.Row="0" Grid.Column="0" Content="1行1列" ></Button>
        <Button Width="100" Height="50" Grid.Row="1" Grid.Column="1" Content="2行2列" ></Button>
        <Button Width="100" Height="50" Grid.Row="2" Grid.Column="2" Content="3行3列" ></Button>
        
    </Grid>

将持续更新

相关推荐
波力海苔夹心脆6752 小时前
C# 序列化与反序列化详解:System.Text.Json、Newtonsoft.Json、XmlSerializer 用法、特性选项与安全实践
经验分享·后端·c#·json·.net
小羊没烦恼!7 小时前
在Scrum中实施敏捷建模
java·开发语言·windows·算法·c#
Lost of 程序猿8 小时前
建造者模式实战:告别“十参数构造函数“的数据导出任务
后端·设计模式·c#·asp.net
mudtools10 小时前
在.NET现有系统中快速集成飞书任务分配能力
后端·c#·.net
SamChan9012 小时前
PDF翻译时页眉页脚总在捣乱?跨页重复文本块的检测与过滤实测
人工智能·python·ai·pdf·wpf
工具派13 小时前
Word文档太大怎么拆分?段落结构与两种拆法的边界实测
开发语言·c#·word
潜龙952713 小时前
需求文档一键变测试用例:手工用例智能生成平台
开发语言·c#
Lost of 程序猿13 小时前
命令模式实战:把“下单后的动作“打包成可执行的任务
后端·设计模式·c#·asp.net·命令模式
淡海水14 小时前
16-01-C#数据结构源码-附录A-术语表
unity·c#·游戏引擎·il2cpp
小羊没烦恼!14 小时前
【译】利用Asp.net MVC处理文件的上传下载
开发语言·缓存·c#·word·powerpoint·.net