0

TextBlocks のサイズを調整しようとすると問題が発生します。3 列と 6 行のグリッドがあり、2 番目の列には各行に TextBlock があり、各 TextBlock テキストの長さが異なるため、ウィンドウのサイズを変更すると、一部のテキストが他のテキストよりも大きくまたは小さく見えます。

ウィンドウのサイズを変更するときに各 TextBlock を同じスケールにする方法はありますか? ウィンドウのサイズを変更すると、すべての TextBlock が同じサイズに見えるようになります。

これは私が持っているコードです:

<Grid Name="grid">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Viewbox Grid.Column="1">
        <TextBlock x:Name="txt1" Text="Some long text 12345" FontSize="20" />
    </Viewbox>

    <Viewbox Grid.Column="1" Grid.Row="1">
        <TextBlock x:Name="txt2" Text="Some longer text 1234567890" FontSize="20" />
    </Viewbox>

    <Viewbox Grid.Column="1" Grid.Row="2">
        <TextBlock x:Name="txt3" Text="Text3" FontSize="20" />
    </Viewbox>

    <Viewbox Grid.Column="1" Grid.Row="3">
        <TextBlock x:Name="txt4" Text="Text4" FontSize="20" />
    </Viewbox>

    <Viewbox Grid.Column="1" Grid.Row="4">
        <TextBlock x:Name="txt5" Text="Text5" FontSize="20" />
    </Viewbox>

    <Viewbox Grid.Column="1" Grid.Row="5">
        <TextBlock x:Name="txt6" Text="Text6" FontSize="20" />
    </Viewbox>

前もって感謝します、

アルベルト

4

1 に答える 1

0
  1. TextBlock をグリッドに直接配置します。viewBox は必要ありません
  2. *の代わりに設定
  3. ColumnDefination または RowDefination "SharedSizeGroup" で設定できるオプションがもう 1 つあります。同じ名前の行または列は、同じ高さまたは幅を共有します。
于 2013-11-12T02:02:49.617 に答える