当前位置: 首页 > 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.xdnf.cn/news/1422217.html

相关文章:

  • RAG-文本到SQL
  • 国别域名的SEO优势:是否更利于在当地搜索引擎排名?
  • Linux -- 进程间通信【System V共享内存】
  • 软考中级习题与解答——第二章_程序语言与语言处理程序(1)
  • vue社区网格化管理系统(代码+数据库+LW)
  • PRACH物理层详解
  • Flutter Container 阴影设置指南 2025版
  • 【技术选型】大型移动端跨平台应用开发 Flutter VS React Native
  • Web网络开发 -- Vue2基础语法,属性和生命周期
  • 大模型面试题剖析:全量微调与 LoRA 微调
  • TDengine 日期时间函数 DAYOFWEEK 使用手册
  • 特征增强方法【特征构建】
  • 太浅显数学常识暴露太重大数学真相:同样是有首项的无穷数列,此列的项可多于彼列的项
  • 车载卫星通信:让自动驾驶“永不掉线”?
  • STM32项目分享:基于单片机的图书馆座位监测系统
  • Git 版本管理工具基本操作汇总—命令总结
  • 液态神经网络(LNN)2:LTC改进成CFC详细推导过程
  • 使用 BayesFlow 神经网络简化贝叶斯推断的案例分享(二)
  • 液态神经网络:智能制造的新引擎
  • Android Framework打电话禁止播放运营商视频彩铃
  • FastLED库完全指南:打造炫酷LED灯光效果
  • 线程池发生了异常该怎么处理?
  • 多校区学校押金原路退回系统之免安装使用教程——东方仙盟
  • 本地部署开源临时文本分享服务 PrivateBin 并实现外部访问( Windows 版本)
  • AOSP 目录及其作用
  • Minecraft(我的世界)服务器信息查询免费API接口详解
  • golang 14并发编程
  • 轻量实现 OCPP 1.6 JSON 协议(欧洲版)的充电桩调试平台
  • Google Gemini 2.5 Flash Image(Nano-Banana)震撼登场!人人都能免费用的AI修图神器!
  • SQL执行过程及原理详解