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

WPF布局控件之StackPanel

StackPanel

Stack,英文意思是堆栈,StackPanel,意思是堆栈式布局,相当于把控件给堆起来。如果不设置StackPanel中控件的宽高,那么其中控件的宽高是默认和StackPanel一样的,如果设置控件宽高,那么控件还是占一行,只是说控件本身宽高改变。如下:

在这里插入图片描述

<Window x:Class="LearnLayout.StackPanelWin"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:LearnLayout"mc:Ignorable="d"Title="StackPanelWin" Height="450" Width="800"><StackPanel><Button Content="牛马人的一生" Background="lavender" Width="200"/><Button Content="我不是牛马" Background="Pink"/><Button Content="下辈子还当牛马" Background="Snow"/></StackPanel>
</Window>

StackPanel默认是竖向(垂直,Orientation="Vertical")堆起来的,如上所示,如果想要横向(水平),可以通过Orientation="Horizontal"来设置。如下:

在这里插入图片描述

<Window x:Class="LearnLayout.StackPanelWin"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:LearnLayout"mc:Ignorable="d"Title="StackPanelWin" Height="450" Width="800"><StackPanel Orientation="Horizontal"><Button Content="牛马人的一生" Background="lavender" Width="200"/><Button Content="我不是牛马" Background="Pink"/><Button Content="下辈子还当牛马" Background="Snow"/></StackPanel>
</Window>
http://www.lryc.cn/news/2414689.html

相关文章:

  • 宽带网速计算方法
  • 视频编解码基础知识
  • 计算机网络-数据链路层-多图
  • townscaper随机生成城镇算法分析
  • linux中cpio文件如何,linux cpio命令的使用
  • ElasticSearch学习篇10_Lucene数据存储之BKD动态磁盘树(论文Bkd-Tree: A Dynamic Scalable kd-Tree)
  • Unity ECS小知识1 - PhysicsTrigger Event
  • 利用Interceptor拦截NetKeeper账户:技术创新与实用性探析
  • 稳压二极管和雪崩二极管的工作原理及选型学习总结
  • Android UI 详解之ToggleButton按钮和Swith按钮
  • 怎么在桌面上嵌入窗口(使用FindWindow(),FindWindowEx(),EnumChildWindows())
  • ADODB用法详解
  • 去掉字符串首尾逗号_去除字符串首尾空格和特殊字符
  • C/C++数据结构课程设计(15题)[2023-10-29]
  • 致敬mentohust,路由器使用Socket认证华科校园网
  • Python 中如何使用 @property
  • 使用TerminateProcess结束进程时,错误码为5的解决方法
  • 常量指针与指针常量的区别
  • 信道估计(channel estimation)图解——从SISO到MIMO原理介绍
  • tbody标签的作用介绍
  • CreateEvent的理解
  • 短剧小程序源码|小程序短剧平台源码搭建
  • background属性介绍
  • [翻译] LaTeX 中的列表
  • 内存地址的计算方法
  • ROS2 学习笔记(一)新建项目的基础流程
  • 分享个好用的开源录屏工具 Captura
  • 高速收发器之发送器详解(Transmitter)
  • 计算机程序设计艺术 介绍
  • CreateMutex创建互斥内核对象