【发布时间】:2015-02-01 04:14:02
【问题描述】:
我有一个堆栈,堆栈内部有一个网格。
我需要在调整窗口大小时增加堆栈和网格大小。 我将 Stack 和 Grid HorizontalAlignment 设置为 'Stretch'
堆栈工作正常,但当我调整窗口大小时网格大小不会增加
这是我的代码。
<StackPanel Background="Blue" Orientation="Horizontal" HorizontalAlignment="Stretch" Grid.Column="1" Margin="13,0,0,0" >
<Grid HorizontalAlignment="Stretch" Background="Beige" Width="515">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="240" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<Image x:Name="imageMap" Source="Resources/images.jpg" HorizontalAlignment="Stretch" Grid.Row="0" Stretch="Fill" Margin="0,0,0,0" />
</Grid>
</StackPanel>
请指教
【问题讨论】:
-
您认为它可能是您在网格上设置的固定
Width="515"吗? -
我认为在 StackPanel 中使用 Orientation=Horz 和 HorzAlignment=Stretch 时会忽略拉伸
-
作为@ChrisW。已经指出,您已将
Grid设置为固定宽度。当您删除它时,您的Grid应该能够与其父级一起拉伸。 -
固定大小无济于事,但当我删除 Orientation=Horz 时它可以工作.. 谢谢
标签: c# .net wpf xaml user-interface