0

如何将高度绑定TextBlock到父控件的高度?

我有TextBlock一个网格内部,我希望TextBlock Height&Width成为网格单元格的高度和宽度,而无需对值进行硬编码。

干杯

AWC

4

4 回答 4

2

Viewbox是最简单的方法:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>  
  <Viewbox>
   <TextBlock Text="Hello World"/>
   </Viewbox>
  </Grid>
</Page>

希望这可以帮助,

干杯,安瓦卡

于 2010-02-18T14:25:22.403 回答
0

这就是你要找的东西:

<Grid >
 <Grid.RowDefinitions>
    <RowDefinition Height="*" />
 </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
  <TextBlock x:Name="SelectedUserName" Grid.Row="0" Grid.Column="0" ></TextBlock>
 </Grid>
于 2010-02-18T14:36:17.620 回答
0

当文本框位于网格中时,它会从网格单元格的度量中获取其度量。

于 2010-02-18T14:24:38.077 回答
0

你试穿了吗TextBlock

VerticalAlignment="Stretch" HorizontalAlignment="Stretch"

默认情况下!

于 2010-02-18T14:25:26.810 回答