StackPanel

Orientation属性
Orientation属性决定SatckPanel中元素的排列方向,默认为垂直排列 Orientation=“Vertical”

<Window x:Class="StackPanel.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow" Height="350" Width="525"><StackPanel Name="stackPane" Orientation="Vertical"><Label Content="Label" Height="28" /><Button Content="Button1" /><Button Content="Button2" /><Button Content="Button3" /><Button Content="Button4" /></StackPanel>
</Window>

如图所示

将Orientation设置为Orientation="Horizontal"效果如下图

如何设置布局中StackPancel的位置

使用HorizontalAlignment属性设置子元素在布局中的水平位置

<Window x:Class="StackPanel.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow" Height="350" Width="525"><StackPanel Name="stackPane" Orientation="Vertical"><Label Content="Label" Height="28" /><Button Content="Button1" HorizontalAlignment="Left"/><Button Content="Button2" HorizontalAlignment="Stretch"/><Button Content="Button3" HorizontalAlignment="Right"/><Button Content="Button4" HorizontalAlignment="Center"/></StackPanel>
</Window>

使用HorizontalAlignment属性设置子元素在布局中的垂直位置

<Window x:Class="StackPanel.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow" Height="350" Width="525"><StackPanel Name="stackPane" Orientation="Horizontal"><Label Content="Label" Height="28" /><Button Content="Button1" VerticalAlignment="Bottom"/><Button Content="Button2" VerticalAlignment="Center"/><Button Content="Button3" VerticalAlignment="Stretch"/><Button Content="Button4" VerticalAlignment="Top"/></StackPanel>
</Window>

Border

Border元素用于为面板设置边框,BorderThickness属性设置边框宽度,BorderBrush设置边框颜色,CornerRadius设置边框圆角的范围

<Window x:Class="StackPanel.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow" Height="350" Width="525"><Border  BorderThickness="2" BorderBrush="Black" CornerRadius="15"><StackPanel Name="stackPane" Orientation="Vertical"><Label Content="Label" Height="28" /><Button Content="Button1" HorizontalAlignment="Left"/><Button Content="Button2" VerticalAlignment="Center"/><Button Content="Button3" HorizontalAlignment="Right"/><Button Content="Button4" HorizontalAlignment="Center"/></StackPanel></Border>
</Window>

WPF-StackPanel面板相关推荐

  1. WPF 后面板设置16进制颜色,透明;

    16进制颜色 Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F0F0F0") ...

  2. WPF 创建自定义面板

    前面两个章节分别介绍了两个自定义控件:自定义的ColorPicker和FlipPanel控件.接下来介绍派生自定义面板以及构建自定义绘图控件. 创建自定义面板是一种特殊但较常见的自定义控件开发子集.前 ...

  3. WPF中的StackPanel、WrapPanel、DockPanel

    一.StackPanel StackPanel是以堆叠的方式显示其中的控件 1.可以使用Orientation属性更改堆叠的顺序 Orientation="Vertical" 默认 ...

  4. WPF学习笔记——5)WrapPanel面板和DockPanel面板

    上一节我们简单介绍了StackPanel的布局,为了能做出更好看的用户界面,往往一种布局容器是不够的,我们这里介绍了两种布局容器,分别为WrapPanel面板和DockPanel面板布局. 1.Wra ...

  5. WPF入门教程系列十九——ListView示例(一)

    经过前面的学习,今天我做一个比较综合的WPF程序示例,主要包括以下功能: 1) 查询功能.从数据库(本地数据库(local)/Test中的S_City表中读取城市信息数据,然后展示到WPF的Windo ...

  6. c# wpf listbox 高度_WPF快速入门系列(1)——WPF布局概览

    一.引言 关于WPF早在一年前就已经看过<深入浅出WPF>这本书,当时看完之后由于没有做笔记,以至于我现在又重新捡起来并记录下学习的过程,本系列将是一个WPF快速入门系列,主要介绍WPF中 ...

  7. WPF系列学习之三(路由事件)

    路由事件实际上以一上 列三种方式出现.     1.与普通的.net事件类似的直接路由事件.它们起源于一个元素,并且不传递给其他元素.例如:MouseEnter事件.     2.在包含层次中向上传递 ...

  8. 如何学习WPF技术?

    本文由长沙DotNET技术社区[邹溪源]整理,共有7544字,阅读需耗时15分钟. 引言 在桌面开发领域,虽然在某些领域,基于electron的跨平台方案能够为我们带来某些便利,但是由于WPF技术能够 ...

  9. 【转】wpf从我炫系列1----布局控件的使用(上)

    今天我来给大家讲解在学习WPF过程中使用布局控件的一些心得,主要给大家介绍一下一个控件的用法.希望对大家学习Wpf有所帮助. 1.       StackPanel栈面板 2.       WrapP ...

  10. 【转】WPF 入门《常用控件》

    1.GroupBox 注意: GroupBox仍然需要布局容器来放置元素.如: StackPanel面板 1 2 3 4 5 6 7 <GroupBox Header="select ...

最新文章

  1. ECharts 交互组件概述
  2. 不能将参数 2 从“const char *”转换为“LPCWSTR”【转】http://blog.sina.com.cn/s/blog_4a94a0db0100ktxp.html...
  3. 我在51CTO微职位学软考——网络工程师
  4. jzoj6311-Mobitel【dp,整除分块】
  5. 【转】PHP面试题总结
  6. 此 sqltransaction 已完成;它再也无法使用_win10笔记本自带office报错无法激活的解决方法...
  7. 最先进的响应式前端框架:Foundation 5!
  8. 侵犯软件著作权罪量刑标准
  9. TensorFlow基础(1)-中使用多个 Graph
  10. ajax执行成功后,在success回调函数中把后台返回的list还原到html的table中
  11. 腾讯视频QLV格式转换为MP4格式
  12. Js设置Cookie
  13. AutoCAD .Net 创建椭圆Ellipse
  14. 利用指针作为游标,编写程序完成将输入字符串复制到一个字符数组中,要求每复制三个字符之后插入一个空格。 例如,若给a输入字符串:ABCDEFGHKIJK,字符数组中的内容为:ABC DEF GH
  15. 《公安机关办理刑事案件电子数据取证规则》
  16. Planer Reflection
  17. vue2 与 vue3 生命周期对比
  18. 论智能问答中的对抗攻击及防御策略
  19. apmserv mysql,APMServ MySQL 1577错误解决方法
  20. 北洋大时代:大师们的理想国札记-随想篇

热门文章

  1. 动态SLIC加载(DBSLDR)激活win7
  2. Java实现定时任务
  3. 【防爬虫01】通过headers中的user-agent字段来反爬
  4. vs---编写第一个JavaScript程序
  5. PMP考试重点总结八——监控过程组(2)
  6. 五大好用的开源MySQL管理工具
  7. mysql管理工具-SQLyog管理工具
  8. 时区时钟插件html,World Clocks插件,世界时钟Chrome插件,轻松查看各国日期时间...
  9. jquery初级视频教程
  10. Revit 2021 族样板下载