当前位置: 首页 > news >正文

wpf之WrapPanel

前言

WrapPanel类似winform中的FlowLayoutPanel,采用流式布局。

1、Orientation

该属性指定WrapPanel中子空间布局的方向,有水平和垂直方向两种
1)Horizontal 水平方向
子元素Button按照水平方向排列,如果一行排满了自动换下一行

<Window x:Class="wpf之Canvas.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:wpf之Canvas"mc:Ignorable="d"Title="MainWindow" Height="200" Width ="200"><WrapPanel Orientation="Horizontal"    ><Button Width=" 50" Height=" 50" Content=" 1" /><Button Width=" 50" Height=" 50" Content=" 2" /><Button Width=" 50" Height=" 50" Content=" 3" /><Button Width=" 50" Height=" 50" Content=" 4" /><Button Width=" 50" Height=" 50" Content=" 5" /></WrapPanel >
</Window>

在这里插入图片描述

1)Vertical 垂直方向
子元素Button按照垂直方向排列,如果一列排满了自动换下一列

<Window x:Class="wpf之Canvas.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:wpf之Canvas"mc:Ignorable="d"Title="MainWindow" Height="200" Width ="200"><WrapPanel Orientation="Vertical"     ><Button Width=" 50" Height=" 50" Content=" 1" /><Button Width=" 50" Height=" 50" Content=" 2" /><Button Width=" 50" Height=" 50" Content=" 3" /><Button Width=" 50" Height=" 50" Content=" 4" /><Button Width=" 50" Height=" 50" Content=" 5" /></WrapPanel >
</Window>

在这里插入图片描述

马工撰写的年入30万+C#上位机项目实战必备教程(点击下方链接即可访问文章目录)

1、《C#串口通信从入门到精通》
2、《C#与PLC通信从入门到精通 》
3、《C# Modbus通信从入门到精通》
4、《C#Socket通信从入门到精通 》
5、《C# MES通信从入门到精通》
6、《winform控件从入门到精通》
7、《C#操作MySql数据库从入门到精通》

http://www.dtcms.com/a/360993.html

相关文章:

  • 了解软件测试之软件测试技能
  • 第六章:健壮Go应用:工程实践与生产就绪之测试
  • Spring Bean生命周期的完全指南
  • 警告:OPENCV_FFMPEG_READ_ATTEMPTS (current value is 4096)
  • Altium Designer中的Net-Tie:解决多网络合并与电气隔离的利器
  • Spring中bean的作用域
  • [Godot] C#使用Json进行数据结构的保存与加载
  • QT中的TCP
  • 摄像头模块的电子集成设计
  • 开发使用mybatis是用混合模式还是全注解模式
  • pprint:美观打印数据结构
  • Spring Boot 和 Spring Cloud 的原理和区别
  • Spring Boot配置优化:Tomcat+数据库+缓存+日志,全场景教程
  • 单例模式
  • Day19_【机器学习—线性回归 (3)—回归模型评估方法】
  • 网站模板源代码 静态网页网站模板
  • VBA数据库解决方案第二十二讲:根据工作表数据生成数据库中数据表
  • 零售行业的 AI 革命:从用户画像到智能供应链,如何让 “精准营销” 不再是口号?
  • 百胜软件获邀出席第七届中国智慧零售大会,智能中台助力品牌零售数智变革
  • 百胜软件×OceanBase深度合作,赋能品牌零售数字化实践降本增效
  • leetcode 面试题17.19 消失的两个数字
  • Java学习笔记-反射(二)
  • 无公网IP,怎么实现远程调试与APP端api 接入?
  • 红楼梦 AI HTML 分析 - 好了歌
  • MySQL内置的各种单行函数
  • Kafka消息中间件安装配置
  • Ruoyi项目MyBatis升级MyBatis-Plus指南
  • sentinel异常处理机制
  • 2025机器人产业大洗牌:新兴初创企业的技术革命与崛起之路
  • 【Spring Cloud微服务】8.深度实战:微服务稳定性的守护神——Sentinel