Psytronic
Psytronic

Reputation: 6113

Text orientation

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

Upvotes: 2

Views: 4332

Answers (2)

Leom Burke
Leom Burke

Reputation: 8281

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.

Upvotes: 4

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

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>  

Upvotes: 3

Related Questions