【发布时间】:2014-01-30 23:01:45
【问题描述】:
(WPF 新手)我正在查看 WPF 示例:
<Window x:Class="Attempt_XAML.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<Label HorizontalAlignment="Center">A Button Stack</Label>
<Button HorizontalAlignment="Left">Button 1</Button>
<Button HorizontalAlignment="Right">Button 2</Button>
<Button Background="#FFA29494">Button 3</Button>
<Button>Button 4</Button>
</StackPanel>
</Window>
MS 中的注释说明:
HorizontalAlignment 和 StackPanel 中包含的内容的 VerticalAlignment。
但是,结果看起来与我的预期不同。 Button 和 Label 没有垂直拉伸,而只是水平拉伸(即它们不会在两个方向上填满 Window 的整个空间)为什么?
【问题讨论】:
-
查看
StackPanel的Orientation属性。此外,请记住,此面板只会使用其内容所需的空间。