wpf基本布局控件 -- 01
<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的更多相关文章
- 【WPF】布局控件总结
<Canvas>:画布,默认不会自动裁减超出内容,即溢出的内容会显示在Canvas外面,这是因为默认 ClipToBounds="False":可设置ClipToBou ...
- WPF 自适应布局控件
public class KDLayoutGroup : Grid { public double LabelWidth { get; set; } public double GetLabelWid ...
- WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系
WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系: 1.Canvas/WrapPanel控件: 其子控件的HorizontalAlign ...
- WPF自学入门(二)WPF-XAML布局控件
上一篇介绍了xaml基本知识,我们已经知道了WPF简单的语法.那么接下来,我们要认识一下WPF的布局容器.布局容器可以使控件按照分类显示,我们一起来看看WPF里面可以使用哪些布局容器用来布局. 在WP ...
- WPF布局控件常用属性介绍
WPF布局控件常用属性介绍 其它 | 作者:慧都控件网 | 2011-04-06 13:41:57| 阅读 0次 有用(0) 评论(0) 概述:WPF布局控件都是派生自System.Windows ...
- wpf布局控件总结
首先要认识到wpf所有的布局控件都继承自Panel类,Panel类又继承自其他类.继承关系如下: 一.StackPanel布局面板 1.该面板在单行或者单列中以堆栈的形式放置其子元素. 默认情况下,S ...
- WPF 界面布局、常用控件入门教程实例 WPF入门学习控件快速教程例子 WPF上位机、工控串口通信经典入门
WPF(Windows Presentation Foundation)是一种用于创建 Windows 桌面应用程序的框架,它提供了丰富的控件库和灵活的界面布局,可以创建现代化的用户界面.下面是 WP ...
- WPF中Ribbon控件的使用
这篇博客将分享如何在WPF程序中使用Ribbon控件.Ribbon可以很大的提高软件的便捷性. 上面截图使Outlook 2010的界面,在Home标签页中,将所属的Menu都平铺的布局,非常容易的可 ...
- 在WPF程序中将控件所呈现的内容保存成图像(转载)
在WPF程序中将控件所呈现的内容保存成图像 转自:http://www.cnblogs.com/TianFang/archive/2012/10/07/2714140.html 有的时候,我们需要将控 ...
- 布局控件Grid
XAML概述 Silverlight的控件绘制是由XAML语言进行支持的.什么是XAML语言? 简单的说,XAML(Extensible Application Markup Language )是一 ...
随机推荐
- 【Windows】(USB热点连接)使用手机给主机提供热点连网
1.问题起源 昨天跟和几个哥们一起装机,发现安装好的系统, 直连网卡提示安装成功,但是网络设置显示未连接 找不到其他原因的办法下,我们看能不能使用手机对电脑进行连网 2.解决过程 我想到的是,先从手机 ...
- 【BatchProgram】工作用的小工具 - 自动访问常用页面
需求: 我需要打开很多页面,但是忘了收藏的话,每次都要重新去找一遍打开 页面很多,不是一两个了,为什么这么多?因为开发情况就是这样啊: 正式生产一个页面,UAT测试一个页面,本地调试一个页面 每日工作 ...
- 【JavaScript】Jquery事件绑定问题
我们所知道的选择器方式,其中有一种方式是属性选择器: <div style="display: flex; justify-content: space-between;"& ...
- 【DataBase】MySQL 27 函数
一.概述 函数 Function,存储过程的用途一致,减少程序逻辑,和数据库服务的连接次数,提高效率 简化操作,提高SQL重用性 函数 和 存储过程的区别? 存储过程允许多个返回的数据,函数只允许一个 ...
- 【SpringBoot】15 数据访问P3 整合Mybatis
重新建立一个SpringBoot工程 选择依赖组件 然后删除不需要的Maven&Git文件 还是先查看我们的POM文件 整合Mybatis的组件多了这一个,默认的版本是3.5.4 然后再看看整 ...
- 强化学习算法:Learning to Learn: Meta-Critic Networks for Sample Efficient Learning
地址: https://arxiv.org/pdf/1706.09529 作者提出了一种叫做Meta-Critic的框架,该框架可以用于强化学习.监督学习等算法中.该算法在强化学习中可以实现元强化学习 ...
- 如何在通用异常处理时获取到方法名称(获取注解参数JoinPoint)
1.背景 很多时候我们在梳理公共异常时,需要获取到接口的而具体名称,便于很好的提示是那个接口错误了 2.实现逻辑 1.在controller方法上的注解上写方法名称,一般使用了swagger都有方法名 ...
- 从数据到洞察:DataOps加速AI模型开发的秘密实践大公开!
作者 | 代立冬,白鲸开源科技联合创始人&CTO 引言 在AI驱动的商业世界中,DataOps作为连接数据与洞察的桥梁,正迅速成为企业数据战略的核心. 在WOT全球技术创新大会2024·北京站 ...
- 有没有一个适合初学者学习的基于linux的嵌入式综合项目?
一.前言 很多粉丝问我,有没有一个适合初学者学习的嵌入式的Linux的项目? 我之前陆陆续续写过一些适合新手的小项目: <从0写一个<电话号码管理系统>的C入门项目[适合初学者]&g ...
- Ubuntu16.04使用命令行安装jdk1.8
在Ubuntu中安装jdk过于麻烦,有时设置不好可能就没有办法使用,卸载也难以卸载干净,所以这篇文章使用相对简单的命令行来安装jdk,只需简单的四个命令,省去许多麻烦,下面是方法. 进入Ubuntu打 ...