I need to get auto size of TextBlock after rotation. Below is the code I am using to rotate the TextBlock by 90 degree with the help of RenderTransform, But It takes up more space than it needed after rotating.
<Border BorderBrush="Red" BorderThickness="3">
<TextBlock Text="Testing" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<RotateTransform Angle="90"/>
</TextBlock.RenderTransform>
</TextBlock>
</Border>
In WPF, with the help of LayoutTransform, I can able to get the auto size (height and width) of the textblock properly. But in UWP, LayoutTranform is not available.
How can I get correct height and width of Textblock after rotation in UWP?
Regards, Shobika.
You could get height and width value of
TextBlock
withActualHeight
andActualWidth
property. you could also subscribeSizeChanged
event when the size changed, you could get the new size fromSizeChangedEventArgs
. But the actual height and width does not exchange after rotation 90°, so theSizeChanged
will not be invoked.