<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="wdpf入门学习" Height="450" Width="800">
<Grid x:Name="___No_Name_asdasdas">
<!-- 布局选项 二行两列 -->
<Grid.RowDefinitions>
<!-- height属性高度 auto 自适应 根据子元素是否可以撑开 或者固定像素 eg:100
或 比列 2 * 标识是第二行高度的2倍
width 和 height 类似
-->
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions> <!-- 样式的设置
Grid.ColumnSpan="2" 占据 2 列的位置
<Border Background="red" Grid.ColumnSpan="2" Grid.RowSpan="2" />
给整个页面设置ref背景色
-->
<Border Background="red" Grid.ColumnSpan="2" Grid.RowSpan="2" />
<Border Grid.Column="1" Grid.Row="0" Background="yellow" />
<Border Grid.Column="0" Grid.Row="1" Background="pink" />
<Border Grid.Column="1" Grid.Row="1" Background="skyblue" /> <!-- StackPanel 布局控件 水平或者垂直放置元素
默认是垂放置元素的 vertical 是默认垂直排列
Orientation 设置方向 Horizontal 是水平排列
-->
<StackPanel Orientation="Horizontal">
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
<Button Width="100" Height="40" Background="yellow" />
</StackPanel>
<!-- WrapPanel 环绕控件 当水平或垂直空间不够会自动换行
Orientation 默认水平排列 Horization
Vertiavl 垂直排列
-->
<WrapPanel Grid.Row="1" Grid.Column="0" Orientation="Vertical">
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
<Button Width="100" Height="40" />
</WrapPanel>
<!--
停靠面板
最后一个元素默认可以填充{拉伸}剩余所有的空间
LastChildFill = false 设置不填充
DockPanel.Dock 设置元素的方向 -->
<DockPanel Grid.Row="1" Grid.Column="1" LastChildFill="true">
<Button DockPanel.Dock="Bottom" Width="100" Height="40" Background="hotpink" />
<Button DockPanel.Dock="top" Width="100" Height="40" Background="hotpink" />
<Button Width="100" Height="40" Background="hotpink" />
</DockPanel>
<!-- 平均布局 -->
<UniformGrid Grid.Row="0" Grid.Column="1">
<Button Width="100" Height="30" />
<Button Width="100" Height="30" />
<Button Width="100" Height="30" />
<Button Width="100" Height="30" />
<Button Width="100" Height="30" />
<Button Width="100" Height="30" />
</UniformGrid>
</Grid>
</Window>

实现布局:

代码:

<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="wdpf入门学习" Height="450" Width="800">
<Grid>
<!-- 使用两行布局 -->
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition />
</Grid.RowDefinitions> <!-- 默认渲染第一行 -->
<Border Background="#686cc8" /> <!-- 第二行使用 2 列布局 -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions >
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border Background="BLUE" />
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions> <Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions> <Border Margin="5" Background="#7378db" />
<Border Margin="5" Grid.Column="1" Background="#4398cd" />
<Border Margin="5" Grid.Column="2" Background="#e480d5" />
<Border Margin="5" Grid.Column="3" Background="#4db5b1" />
<Border Margin="5" Grid.Column="4" Background="#e17b7b" /> <Border Margin="5" Grid.Row="1" Grid.ColumnSpan="3" Background="red" />
<Border Margin="5" Grid.Row="1" Grid.Column="3" Grid.ColumnSpan="2" Background="yellow" />
<Border Margin="5" Grid.Row="2" Grid.ColumnSpan="3" Background="blue" />
<Border Margin="5" Grid.Row="2" Grid.Column="3" Grid.ColumnSpan="2" Background="green" />
</Grid>
</Grid>
</Grid>
</Window>

wpf基本布局控件 -- 01的更多相关文章

  1. 【WPF】布局控件总结

    <Canvas>:画布,默认不会自动裁减超出内容,即溢出的内容会显示在Canvas外面,这是因为默认 ClipToBounds="False":可设置ClipToBou ...

  2. WPF 自适应布局控件

    public class KDLayoutGroup : Grid { public double LabelWidth { get; set; } public double GetLabelWid ...

  3. WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系

    WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系: 1.Canvas/WrapPanel控件: 其子控件的HorizontalAlign ...

  4. WPF自学入门(二)WPF-XAML布局控件

    上一篇介绍了xaml基本知识,我们已经知道了WPF简单的语法.那么接下来,我们要认识一下WPF的布局容器.布局容器可以使控件按照分类显示,我们一起来看看WPF里面可以使用哪些布局容器用来布局. 在WP ...

  5. WPF布局控件常用属性介绍

    WPF布局控件常用属性介绍 其它 | 作者:慧都控件网 | 2011-04-06 13:41:57| 阅读 0次 有用(0) 评论(0)   概述:WPF布局控件都是派生自System.Windows ...

  6. wpf布局控件总结

    首先要认识到wpf所有的布局控件都继承自Panel类,Panel类又继承自其他类.继承关系如下: 一.StackPanel布局面板 1.该面板在单行或者单列中以堆栈的形式放置其子元素. 默认情况下,S ...

  7. WPF 界面布局、常用控件入门教程实例 WPF入门学习控件快速教程例子 WPF上位机、工控串口通信经典入门

    WPF(Windows Presentation Foundation)是一种用于创建 Windows 桌面应用程序的框架,它提供了丰富的控件库和灵活的界面布局,可以创建现代化的用户界面.下面是 WP ...

  8. WPF中Ribbon控件的使用

    这篇博客将分享如何在WPF程序中使用Ribbon控件.Ribbon可以很大的提高软件的便捷性. 上面截图使Outlook 2010的界面,在Home标签页中,将所属的Menu都平铺的布局,非常容易的可 ...

  9. 在WPF程序中将控件所呈现的内容保存成图像(转载)

    在WPF程序中将控件所呈现的内容保存成图像 转自:http://www.cnblogs.com/TianFang/archive/2012/10/07/2714140.html 有的时候,我们需要将控 ...

  10. 布局控件Grid

    XAML概述 Silverlight的控件绘制是由XAML语言进行支持的.什么是XAML语言? 简单的说,XAML(Extensible Application Markup Language )是一 ...

随机推荐

  1. 【C3】04 工作原理

    我们已经知道了CSS是做什么的以及怎么写简单的样式这样基础的CSS, 接下来我将了解到浏览器如何获取CSS.HTML和将他们加载成网页. 前置知识: 基础计算机知识.基本软件安装.简单文件知识.HTM ...

  2. 【Tutorial C】03 数据类型、变量

    在程序的世界中,可以让计算机按照指令做很多事情, 如进行数值计算.图像显示.语音对话.视频播放.天文计算.发送邮件.游戏绘图以及任何我们可以想象到的事情. 要完成这些任务,程序需要使用数据,即承载信息 ...

  3. 【Tutorial C】05 操作符 & 表达式

    基本运算符 C使用运算符(operator)来代表算术运算.例如,+运算符可以使它两侧的值加在一起. 如果您觉得术语"运算符"听起来比较奇怪,那么请您记住那些东西总得有个名称. 与 ...

  4. Python的GDAL库绘制多波段、长时序遥感影像时间曲线图

      本文介绍基于Python中的gdal模块,对大量长时间序列的栅格遥感影像文件,绘制其每一个波段中.若干随机指定的像元的时间序列曲线图的方法.   在之前的文章中,我们就已经介绍过基于gdal模块, ...

  5. 斯坦福AI团队被质疑抄袭国产大模型

    原文地址: https://mbd.baidu.com/newspage/data/landingsuper?context={"nid"%3A"news_8882699 ...

  6. 深度学习框架 MindSpore —— 华为出品的AI计算框架, docker 安装

    深度学习框架  MindSpore  --   华为出品的AI计算框架 官网地址: https://www.mindspore.cn/ 源代码地址: https://gitee.com/devilma ...

  7. AQS源码深度解析之cancelAcquire方法解读

    1.背景 2.源码解读 调用该方法的地方 方法源码解读 /** * 取消获取资源(异常处理时都需要用到) * 方法主要功能: * 1.处理当前取消节点的状态: * 2.将当前取消节点的前置非取消节点和 ...

  8. 曝光!Apache SeaTunnel Catalog 功能设计为何能大大简化用户启用步骤?

    Catalog(目录)提供了关于数据库.表格和访问数据所需的信息的元数据,以及统一的 API 来管理元数据,验证连接,让元数据对 Sources(数据源).Sinks(数据汇)和 Web 可访问. C ...

  9. 使用Typora编写后的md文件优雅的上传到博客(插件dotnet-cnblog的使用)

    一.Typora的设置 如下图,设置图片上传位置 之后文章上的图片都会临时存放到文件同级目录下的xxx.Asster文件夹下面. 二.下载插件dotnet-cnblog 1.安装.Net Core S ...

  10. java本地增量打包工具

    在打增量包每次都需要将class文件.jsp文件等拷贝到增量包中比较麻烦.所以就写了一个增量打包工具. 工作原理:根据文件的最后修改时间来打增量. 1.查找Java类增量:根据eclipse工程下的. ...