How to rotate Text in WPF by keeping the Auto-Sizing function
I want to have an text vertical. I just use a simple grid in WPF to auto-size the areas. But when using RotateTransform
, all calculations are wrong. Any idea how to solve this?
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
Use a LayoutTransform
instead of a RenderTransform
. It gets applied during the layout pass, not during rendering.
Like Rachel said use LayoutTransform
<TextBlock Text="Goodday" >
<TextBlock.LayoutTransform>
<RotateTransform Angle="90" />
</TextBlock.LayoutTransform>
</TextBlock>
<TextBlock Height="14"
x:Name="TextBlock1"
Text="Vertical Bottom to Up" Margin="73,0,115,0" RenderTransformOrigin="0.5,0.5" >
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
精彩评论