Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate Text in WPF by keeping the Auto-Sizing function

Tags:

text

rotation

wpf

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> 

WPF rotate text In this image you see what I mean. If I now want to auto-size the middle part I cannot use "Width" or "Height" property because both will raise a wrong sizing result. Width =120px will increase the horicontal (original) width and will make the complete row 120pixel. Height=120px will make the text 120pixel height.

like image 554
Nasenbaer Avatar asked Jun 23 '11 17:06

Nasenbaer


People also ask

How do I rotate text in WPF?

RotateTransform rotates an element clockwise by a specified angle about the point. The RotateTransform object in WPF represents RotateTransform. The Angle property represents the angle in degrees to rotate clockwise. The CenterX and CenterY properties represent the X and Y coordinates of the center point.

How do you rotate a shape in WPF?

The CenterX and CenterY properties of the RotateTransform specify the point about which the object is rotated. This center point is expressed in the coordinate space of the element that is transformed. By default, the rotation is applied to (0,0), which is the upper-left corner of the object to transform.


1 Answers

Use a LayoutTransform instead of a RenderTransform. It gets applied during the layout pass, not during rendering.

like image 139
Rachel Avatar answered Oct 05 '22 22:10

Rachel