布局篇-StackPanel布局

StackPanel可以把内部元素在纵向或横向上紧凑排列,形成栈式布局

 

StackPanel的三个属性
属性名称 数据类型 可取值 描述
Orientation Orientation枚举
Horizontal
Vertical
决定内部元素是横向累积还是纵向累积
HorizontalAlignment HorizontalAlignment枚举
Left
Center
Right
Stretch
决定内部元素水平方向上的对齐方式
VerticalAlignment VerticalAlignment
Top
Center
Bottom
Stretch
决定内部元素竖直方向上的对齐方式

 

实例代码

[html] view plain copy
 
  1. <Grid>  
  2.     <GroupBox Header="请选择没有错别字的成语"  BorderBrush="Black" Margin="5">  
  3.         <StackPanel Margin="5" Height="271">  
  4.             <CheckBox Content="A.迫不及待" />  
  5.             <CheckBox Content="B.首屈一指" />  
  6.             <CheckBox Content="C.陈词滥调" />  
  7.             <CheckBox Content="D.不可理喻" />  
  8.             <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">  
  9.                 <Button Content="清空" Width="60" Margin="5" />  
  10.                 <Button Content="确定" Width="60" Margin="5" />  
  11.             </StackPanel>  
  12.         </StackPanel>  
  13.     </GroupBox>  
  14. </Grid>  


效果如图:

posted on 2017-07-26 08:47  alex5211314  阅读(183)  评论(0编辑  收藏  举报

导航