当文本块旋转90度时,XAML RT网格行高不会自动调整大小

时间:2013-08-19 08:09:56

标签: wpf xaml grid winrt-xaml

我有一个包含3行的XAML RT网格。我在第1行第0列有一个文本块,我将文本旋转了90度。行的高度已设置为自动,但行的高度不会自动调整为旋转的文本块的高度。有人可以帮忙吗?

网格的代码如下:

<Grid x:Name="gridDetails" Height="200"
      Margin="2"          
      Background="Yellow">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition  />
    </Grid.RowDefinitions>

    <TextBlock Grid.Row="0"
               Grid.Column="1">
        <Run Text="Header" />
    </TextBlock>
    <TextBlock Grid.Row="1"
               Margin="0"                   
               RenderTransformOrigin="0.5,0.5"  >
        <TextBlock.RenderTransform>
            <CompositeTransform Rotation="-90" />
        </TextBlock.RenderTransform>
            <Run Text="Sample Text" />
    </TextBlock>        
</Grid>

这是一个使用XAML RT和c#的窗口8商店应用程序。

由于

2 个答案:

答案 0 :(得分:2)

您所看到的行为是RenderTransform所期望的,它只会影响渲染,而不会影响布局。

此链接可能会有所帮助: http://igrali.com/2012/09/17/layout-transform-in-windows-8-winrt-xaml/

答案 1 :(得分:0)

您必须使用LayoutTransform而不是RenderTransform。

有关详细信息,请参阅MSDN:http://msdn.microsoft.com/en-us/library/ms750596.aspx#exampleRotateAnElement45degSection