Reputation: 21
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.
Upvotes: 0
Views: 231
Reputation: 32775
You could get height and width value of TextBlock
with ActualHeight
and ActualWidth
property. you could also subscribe SizeChanged
event when the size changed, you could get the new size from SizeChangedEventArgs
. But the actual height and width does not exchange after rotation 90°, so the SizeChanged
will not be invoked.
Upvotes: 0