对齐和内容对齐

HorizontalAlignmentLeft,Center,Hight,Stretch(default)

VerticalAlignmentTop,Center,Bottom,Stretch(default)

可以让一个元素自己决定如何使用父面板给它的额外空间。

只有当一个父面板给子元素的空间比子元素真正需要的多时,这两个属性才是有用的。

 

HorizontalContentAlignmentLeftdefault,Center,Hight,Stretch

 

VerticalContentAlignmentTopdefault,Center,Bottom,Stretch

 

这两个属性决定控件的内容怎样填满控件的内部空间。

<StackPanel>

            <Button HorizontalAlignment="Left" Background="Red">Left</Button>

            <Button HorizontalAlignment="Center" Background="Orange">Center</Button>

            <Button HorizontalAlignment="Right" Background="Yellow">Right</Button>

            <Button HorizontalAlignment="Stretch" Background="Linen">Stretch</Button>

</StackPanel>

<StackPanel>

            <Button HorizontalContentAlignment="Left" Background="Red">Left</Button>

            <Button HorizontalContentAlignment="Center" Background="Orange">Center</Button>

            <Button HorizontalContentAlignment="Right" Background="Yellow">Right</Button>

            <Button HorizontalContentAlignment="Stretch" Background="Linen">Stretch</Button>

</StackPanel>

 

 
posted @   quietwalk  阅读(332)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示