WPF布局(1) 使用StackPanel面板进行简单的布局

StackPanel 面板是简单的布局容器。该面板简单地在单行或单列中以堆栈的形式放置其中的子元素,默认情况StackPanel是自上而下排列元素,标签和按钮的大小刚好足够适合它们内部包含的文本。,也可以设置Orientantion 属性,使StackPanel面板水平排列元素

例如

<Window x:Class="Project03_01StackPanel.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Border Margin="5" Padding="5" Background="LightYellow" BorderBrush="SteelBlue"
            BorderThickness="3,5,3,5" CornerRadius="3">
    <StackPanel >
        <Label HorizontalAlignment="Center">A Button Stack</Label>
        <Button Margin="3" MaxWidth="200"  MinWidth="100" HorizontalAlignment="Left">Button 1</Button>
        <Button Margin="3" MaxWidth="200" MinWidth="100" HorizontalAlignment="Right">Button 2</Button>
        <Button Margin="3" MaxWidth="200" MinWidth="100">Button 3</Button>
        <Button Margin="3" MaxWidth="200" MinWidth="100">Button 4</Button>
    </StackPanel>
    </Border>
</Window>
效果图:

转载于:https://www.cnblogs.com/WilliamJiang/archive/2011/12/27/2302722.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值