2010-02-18 94 views
0

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

我有一个TextBlock一个网格内,我想在TextBlockHeight & Width是网格单元的高度&宽度没有硬编码的值。

干杯

AWC

回答

0

当一个文本框,在它得到其测量从网格单元的测量网格。

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> 

希望这有助于

干杯,Anvaka

0

你有没有尝试在TextBlock

VerticalAlignment="Stretch" HorizontalAlignment="Stretch" 

在缺省情况下!

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>