我在6x2网格中有几个TextBlocks,需要在父控件调整大小时调整文本TextBlocks中的文本大小。我不知道如何做到这一点,对WPF来说还是一个新手。我是一本关于WPF的书的几章!
我不知道怎么回事。有人可以帮忙吗?
标记
答案 0 :(得分: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>