1

在 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>
4

1 回答 1

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>
于 2011-07-12T07:44:02.800 回答