I want to write text vertically inside of a border element. As shown in this picture.
I've tried using RenderTransform with this code
<Border Width="80"
Background="Teal">
<TextBlock Text="CATEGORIES"
Foreground="White"
FontFamily="Segoe UI Black"
FontSize="30">
<TextBlock.RenderTransform>
<RotateTransform Angle="-90" />
</TextBlock.RenderTransform>
</TextBlock>
</Border>
This rotates the text vertically but the TextBlock takes the old values of height and width before Transform and doesn't display the text completely. So the text is cut off after 80 pixels (width of the border element). While searching I found using LayoutTransform can solve the problem but it is not available in UWP apps. How to do this in UWP XAML?
This worked for me on UWP as well. Just use the class posted here instead of the one from the post. And also copy the style from the blog post.
EDIT: The onedrive link no longer works. So I am posting the code here.
Create a new class LayoutTransformer
In the App.xaml file
Add namespace common
create a new style inside of ApplicationResources
Now to rotate a textblock anticlockwise by 90 degrees
Add namespace common
And use this code
If you rotate the Border (the parent), TextBlock will be rotated as well since it is the child of the Border.