2010-02-18 109 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>