wpf controls - WPF, TextBlock Rotation, Alignment Issues -


enter image description herei 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

enter image description here


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -