StackPanel可以把内部元素在纵向或横向上紧凑排列,形成栈式布局
StackPanel的三个属性
属性名称 | 数据类型 | 可取值 | 描述 | ||||
Orientation | Orientation枚举 |
| 决定内部元素是横向累积还是纵向累积 | ||||
HorizontalAlignment | HorizontalAlignment枚举 |
| 决定内部元素水平方向上的对齐方式 | ||||
VerticalAlignment | VerticalAlignment |
| 决定内部元素竖直方向上的对齐方式 |
实例代码
<
Grid>
< GroupBox Header= "请选择没有错别字的成语" BorderBrush= "Black" Margin= "5">
< StackPanel Margin= "5" Height= "271">
< CheckBox Content= "A.迫不及待" />
< CheckBox Content= "B.首屈一指" />
< CheckBox Content= "C.陈词滥调" />
< CheckBox Content= "D.不可理喻" />
< StackPanel Orientation= "Horizontal" HorizontalAlignment= "Right">
< Button Content= "清空" Width= "60" Margin= "5" />
< Button Content= "确定" Width= "60" Margin= "5" />
< /StackPanel>
< /StackPanel>
< /GroupBox>
< /Grid>
< GroupBox Header= "请选择没有错别字的成语" BorderBrush= "Black" Margin= "5">
< StackPanel Margin= "5" Height= "271">
< CheckBox Content= "A.迫不及待" />
< CheckBox Content= "B.首屈一指" />
< CheckBox Content= "C.陈词滥调" />
< CheckBox Content= "D.不可理喻" />
< StackPanel Orientation= "Horizontal" HorizontalAlignment= "Right">
< Button Content= "清空" Width= "60" Margin= "5" />
< Button Content= "确定" Width= "60" Margin= "5" />
< /StackPanel>
< /StackPanel>
< /GroupBox>
< /Grid>
效果如图:

原文地址:http://blog.youkuaiyun.com/iamsupercola/article/details/7039542