前言
Wpf之布局属性!
一、布局属性
布局属性,只要是继承了FrameWork基类就可以使用下面的属性
属性 | 作用 | 用法 |
---|---|---|
HorizontalAlignment | 当水平方向上有额外的空间时,子元素在布局容器中的定位方式,可选值有 Center、Left、Right 或 Stretch 等 | <Button Content="Button" HorizontalAlignment="Center"/> |
VerticalAlignment | 当垂直方向上有额外的空间时,子元素在布局容器中的定位方式,可选值有 Center、Top、Bottom 或 Stretch 等 | <Button Content="Button" VerticalAlignment="Top"/> |
Margin | 用于在元素周围添加空间,可分别设置顶部、底部、左边和右边的空间 | <Button Content="Button" Margin="10,5,10,5"/> |
MinWidth 和 MinHeight | 设置元素的最小尺寸,元素不会小于该尺寸 | <Button Content="Button" MinWidth="100" MinHeight="50"/> |
MaxWidth 和 MaxHeight | 设置元素的最大尺寸,元素不会大于该尺寸 | <Button Content="Button" MaxWidth="200" MaxHeight="100"/> |
Width 和 Height | 显式设置元素的尺寸,会覆盖 HorizontalAlignment 和 VerticalAlignment 的 Stretch 设置,但受 Min 和 Max 属性限制 | <Button Content="Button" Width="150" Height="75"/> |