0

我在 6x2 网格中有几个 TextBlocks,并且需要在父控件调整大小时调整文本 TextBlocks 中的文本大小。我不知道该怎么做,而且对 WPF 很陌生。我在一本关于 WPF 的书中写了几章!

我不知道该怎么做。任何人都可以帮忙吗?

标记

4

1 回答 1

1

这个怎么样 - 它在每个网格单元格中都有视图框和一个文本框作为它的内容。它会在您调整应用程序大小时调整内容大小

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="286" Width="440">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition ></RowDefinition>
            <RowDefinition ></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <Viewbox Grid.Column="0" Grid.Row="0">
            <TextBlock Text="1"  HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox  Grid.Column="1" Grid.Row="0">
        <TextBlock Text="1" HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox  Grid.Column="2" Grid.Row="0">    
            <TextBlock Text="1" HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox Grid.Column="3" Grid.Row="0">
            <TextBlock Text="1"  HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox Grid.Column="4" Grid.Row="0">
            <TextBlock Text="1" HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox Grid.Column="5" Grid.Row="0">
            <TextBlock Text="1"  HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>


        <Viewbox Grid.Column="0" Grid.Row="1">
            <TextBlock Text="1"  HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox  Grid.Column="1" Grid.Row="1">
            <TextBlock Text="1" HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox  Grid.Column="2" Grid.Row="1">
            <TextBlock Text="1" HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox Grid.Column="3" Grid.Row="1">
            <TextBlock Text="1"  HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox Grid.Column="4" Grid.Row="1">
            <TextBlock Text="1" HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
        <Viewbox Grid.Column="5" Grid.Row="1">
            <TextBlock Text="1"  HorizontalAlignment="Stretch"></TextBlock>
        </Viewbox>
    </Grid>
</Window>
于 2013-08-01T10:40:25.213 回答