Vertical Text in Wpf TextBlock


Is it possible to display the text in a TextBlock vertically so that all letters are stacked upon each other (not rotated with LayoutTransform)?

12/8/2008 3:34:32 PM

Accepted Answer

Nobody has yet mentioned the obvious and trivial way to stack the letters of an arbitrary string vertically (without rotating them) using pure XAML:

  ItemsSource="Text goes here, or you could use a binding to a string" />

This simply lays out the text vertically by recognizing the fact that the string is an IEnumerable and so ItemsControl can treat each character in the string as a separate item. The default panel for ItemsControl is a StackPanel, so the characters are laid out vertically.

Note: For precise control over horizontal positioning, vertical spacing, etc, the ItemContainerStyle and ItemTemplate properties can be set on the ItemsControl.

2/6/2012 8:37:58 PM

Just in case anybody still comes across this post... here is a simple 100% xaml solution.

    <TabControl TabStripPlacement="Left">
        <TabItem Header="Tab 1">
                <RotateTransform Angle="-90"></RotateTransform>      
            <TextBlock> Some Text for tab 1</TextBlock>
        <TabItem Header="Tab 2">
                <RotateTransform Angle="-90"></RotateTransform>
            <TextBlock> Some Text for tab 2</TextBlock>

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow