Textblock占用相同的水平空间甚至应用RotateTransform

时间:2011-05-26 14:18:47

标签: wpf xaml

我在文本块上应用RotateTransform,使其垂直显示文本而不是水平显示文本,但在未进行转换时水平占用相同的空间。请建议解决方案,以消除这种暴露的sapce。

<Border  BorderBrush="#888888" BorderThickness="0,0,2,0">
    <TextBlock FontFamily="Arial" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" FontSize="15" Text="Menu" >
        <TextBlock.RenderTransform>
            <RotateTransform Angle="270" />
        </TextBlock.RenderTransform>
     </TextBlock>
</Border>

1 个答案:

答案 0 :(得分:5)

Use LayoutTranform instead of RenderTransform

<Border  BorderBrush="#888888" BorderThickness="0,0,2,0">
    <TextBlock FontFamily="Arial" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" FontSize="15" Text="Menu" >
        <TextBlock.LayoutTransform>
            <RotateTransform Angle="270" />
        </TextBlock.LayoutTransform>
     </TextBlock>
</Border>