StackPanel

Window可以只包含一个元素,作为其内容。如果要在其中包含多个元素,就可以将StackPanel用作Window的一个子元素,并在StackPanel的内容中添加元素。StackPanel是一个简单的容器控件,只能逐个排序地显示元素。StackPanel的方向可以是水平或垂直。

<Window x:Class="Panel布局.StackPanel"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="StackPanel" Height="300" Width="300">
    <StackPanel Orientation="Vertical">
        <Button Height="30">ButtonA</Button>
        <Button Height="30">ButtonB</Button>
        <Button Height="30">ButtonC</Button>
        <Button Height="30">ButtonD</Button>
    </StackPanel>
</Window>

原文地址:https://www.cnblogs.com/hdsong/p/5076288.html