在WPF中, 如何在一个区域(宽阔的水平区域)上传播/拉伸内容?
像这样:
这是我当前的代码(来自图片的上半部分):
<Grid Width="900">
<ScrollViewer x:Name="sclScroller" HorizontalScrollBarVisibility="Hidden">
<Viewbox HorizontalAlignment="Stretch">
<DockPanel>
<TextBlock Name="txtContent1" Text="1" />
<TextBlock Name="txtContent2" Text="2" />
<TextBlock Name="txtContent3" Text="3" />
<TextBlock Name="txtContent4" Text="4" />
<TextBlock Name="txtContent5" Text="5" />
<TextBlock Name="txtContent6" Text="6" />
<TextBlock Name="txtContent7" Text="7" />
<TextBlock Name="txtContent8" Text="8" />
</DockPanel>
</Viewbox>
</ScrollViewer>
</Grid>
答案 0 :(得分:0)
使用统一网格可以做类似的事情。
<UniformGrid Rows="1" Columns="8">
<UniformGrid.Resources>
<Style TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center"></Setter>
</Style>
</UniformGrid.Resources>
<TextBlock Name="txtContent1" Text="1" />
<TextBlock Name="txtContent2" Text="2" />
<TextBlock Name="txtContent3" Text="3" />
<TextBlock Name="txtContent4" Text="4" />
<TextBlock Name="txtContent5" Text="5" />
<TextBlock Name="txtContent6" Text="6" />
<TextBlock Name="txtContent7" Text="7" />
<TextBlock Name="txtContent8" Text="8" />
</UniformGrid>