wpf controls - WPF, TextBlock Rotation, Alignment Issues -
i rotate textblock based on text's center point [horizontal , vertical). have tried following code. taking topleft corner of textblock. how change center of text itself.
<textblock name="textblock1" textwrapping="wrap" fontsize="25" foreground="#fff63aff" fontweight="bold"> textblock <textblock.rendertransform> <transformgroup> <rotatetransform angle="45" /> </transformgroup> </textblock.rendertransform> </textblock>
image description: textblock part of canvas , textblock should rotate based on intersection shown in image
i have tried horizontalalignment verticalalignment too, taking parent's alignment details.
do need actual width , actual height, based on details calculate center point?
you need use rendertransformorigin=".5,.5"
<grid> <textblock name="textblock1" rendertransformorigin=".5,.5" horizontalalignment="center" verticalalignment="center" textwrapping="wrap" fontsize="25" foreground="#fff63aff" fontweight="bold"> textblock <textblock.rendertransform> <transformgroup> <rotatetransform angle="45" /> </transformgroup> </textblock.rendertransform> </textblock> </grid>
output
Comments
Post a Comment