2

I know you can do this to get vertical text in a tab header:

<Window x:Class="Abodemploy.Window1"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    Title="Window1" Height="300" Width="300">  
    <Grid>  
        <TabControl Margin="0" Name="tabControl1" FlowDirection="LeftToRight" TabStripPlacement="Left">  
            <TabItem>  
                <TabItem.Header>  
                    <StackPanel Orientation="Horizontal">  
                        <TextBlock>Homes</TextBlock>  
                    </StackPanel>  
                </TabItem.Header>  
                <TabItem.LayoutTransform>  
                <TransformGroup>  
                    <RotateTransform Angle="90" />  
                </TransformGroup>  
                </TabItem.LayoutTransform>  
                <Grid />  
            </TabItem>  
        </TabControl>  
    </Grid>  
</Window>  

However the text letters are sideways. What I'd like (if possible) is for the letter orientation to be correct (ie upwards), but the text flow downwards, is this possible, or am I just dreaming the impossible dream?

Thanks Psy

1
  • Could you do this by setting the width to a very small number and turning on text wrapping? Commented Oct 17, 2018 at 13:48

2 Answers 2

4

I think the following post answers your question: vertical-text-in-wpf-textblock

and I was able to get the desired result as follows:

XAML

<Window x:Class="Test.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <TabControl Margin="0" Name="tabControl1" FlowDirection="LeftToRight" TabStripPlacement="Left">
            <TabItem>
                <TabItem.Header>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock >
                            <ItemsControl x:Name="ic"></ItemsControl>
                        </TextBlock>
                    </StackPanel>
                </TabItem.Header>
                <Grid />
            </TabItem>
        </TabControl>
    </Grid>
</Window>

And then set the ItemsSource of the ItemsControl to the string you want in the code behind.

3
  • Yes, I was looking for a similar question and couldn't find it, then when I was looking for a different issue I came across this answer, and yup, it works
    – Psytronic
    Commented Mar 18, 2010 at 12:02
  • Had to make a few changes, and now the tab headers are stupidly wide, but its what I needed
    – Psytronic
    Commented Mar 18, 2010 at 12:10
  • Cool - glad you got it sorted
    – Leom Burke
    Commented Mar 18, 2010 at 12:22
3

Do you ask for this?

 <TabItem.Header>  
      <StackPanel>  
            <TextBlock>H</TextBlock>  
            <TextBlock>o</TextBlock>
            <TextBlock>m</TextBlock>  
            <TextBlock>e</TextBlock>
            <TextBlock>s</TextBlock>
      </StackPanel>  
 </TabItem.Header>  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.