WPF控件学习系列---StackPanel控件
来源:互联网 发布:ubuntu修复grub引导 编辑:程序博客网 时间:2024/06/09 22:52
WPF StackPanel
图1.1
Introduction介绍
The StackPanel
in WPF is a simple and useful layout panel. It stacks its child elements below or beside each other, dependening on its orientation. This is very useful to create any kinds of lists. All WPF ItemsControls
like ComboBox
, ListBox
or Menu
use a StackPanel as their internal layout panel.
WPF中的StackPanel控件是一种简单常用的布局控件。它可根据orientation属性设置面板里面的每个子元素是依靠在前一个控件的旁边(横向)还是下面(纵向)。对于创建各种类型的列表非常有用。所有的继承于ItemsControls的WPF控件,如ComboBox,ListBox和Menu控件都可以使用StackPanel做为它的内部布局面板。
<StackPanel>
<TextBlock Margin="10" FontSize="20">How do you like your coffee?</TextBlock>
<Button Margin="10">Black</Button>
<Button Margin="10">With milk</Button>
<Button Margin="10">Latte machiato</Button>
<Button Margin="10">Chappuchino</Button>
</StackPanel>
上面这一段代码将把StackPanel面板里面的每个控件,从上往下排列,如图1.1所示。
Stack Items horizontally
A good example for a horizontal stack panel are the "OK" and "Cancel" buttons of a dialog window. Because the size of the text can change if the user changes the font-size or switches the language we should avoid fixed sized buttons. The stack panel aligns the two buttons depending on their desired size. If they need more space they will get it automatically. Never mess again with too small or too large buttons.
有一个很好的例子,如有一个有“OK"和"Cancel“按钮的对话框,因为按钮上的文字可能因字体的改变而发生大小改变,我们应该避免固定按钮大小的写法。StackPanel会自动根据面板的大小的自动调整内部控件的大小。我们就不用为按钮太大或太小而烦恼了。
<StackPanel Margin="8" Orientation="Horizontal"> <Button MinWidth="93">OK</Button> <Button MinWidth="93" Margin="10,0,0,0">Cancel</Button></StackPanel>
2010-04-16
本文摘抄翻译自http://www.wpftutorial.net/StackPanel.html
- WPF控件学习系列---StackPanel控件
- WPF控件-StackPanel控件
- 自学WPF--第七课StackPanel控件
- wpf之布局控件stackpanel、wrappanel、dockpanel的前世今生
- wpf学习笔记---StackPanel
- WPF-StackPanel学习
- StackPanel控件的使用
- 四、StackPanel控件
- WPF控件学习系列之二---DockPanel控件
- WPF控件学习系列之三---GridPanel控件
- WPF控件学习系列之四---WrapPanel控件
- WPF控件学习系列之五---CanvasPanel控件
- WPF ListBox控件学习
- WPF学习之控件
- wpf-控件学习
- wpf window stackpanel等控件的双击放大缩小主窗体事件
- WPF学习笔记--控件模板
- 学习WPF基本控件属性
- 使用JNI技术实现JAVA程序调用dll
- Diskpart 命令行实用工具介绍
- (转)onInterceptTouchEvent和onTouchEvent调用时序
- 临时表解析
- datarec.cpp
- WPF控件学习系列---StackPanel控件
- 备忘:oracle遇到的应用
- datarec.h
- 如何通过序列化在网络间传递对象,网络协议:轻松定义自己的网络通讯协议
- 简单WINFORM安装程序制作
- Oracle7
- liset.cpp
- liset.h
- my_button.cpp