【发布时间】:2017-09-08 11:10:37
【问题描述】:
我有一个网格(见下图),其中包含一些文本(在另一个网格中(粉色区域))和一个 Datagrid,其中包含几行分类数据(蓝色区域)。
蓝色区域始终位于底部并具有固定高度并且工作正常。然而,粉红色的网格位于视图框内,因此它会根据屏幕/浏览器的大小进行拉伸。拉伸按我想要的方式工作,但我想将视图框与左上角对齐。 问题是如果我将视图框对齐到左上角,拉伸就消失了。
到目前为止我尝试了什么..
拉伸可以,但未对齐:
<Border BorderThickness="1" BorderBrush="Black">
<Grid Background="Gold">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Viewbox Grid.Row="0">
<Grid Background="HotPink">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="A"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="B"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="C"/>
<TextBlock Grid.Column="1" Grid.Row="1" Text="D"/>
</Grid>
</Viewbox>
<Rectangle Grid.Row="1" Height="50" HorizontalAlignment="Stretch" Fill="DeepSkyBlue"></Rectangle>
</Grid>
</Border>
导致..
对齐没问题,但拉伸消失了:
<Border BorderThickness="1" BorderBrush="Black">
<Grid Background="Gold">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Viewbox Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid Background="HotPink">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="A"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="B"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="C"/>
<TextBlock Grid.Column="1" Grid.Row="1" Text="D"/>
</Grid>
</Viewbox>
<Rectangle Grid.Row="1" Height="50" HorizontalAlignment="Stretch" Fill="DeepSkyBlue"></Rectangle>
</Grid>
</Border>
导致..
但我真正想要的是: (我希望上面的代码能够实现)
非常感谢任何帮助。
【问题讨论】:
标签: silverlight alignment viewbox