3

This Expander is vertical. The Header displays as Hightlight

I want

H
i
g
h
l
i
g
h
t

How do it get that?

 <Expander Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right"
    VerticalAlignment="Stretch" Header="Highlight" 
    ExpandDirection="Left" IsExpanded="False" Width="Auto">

And the solution is

   <Expander Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Stretch" ExpandDirection="Left" IsExpanded="False" Width="Auto">
        <Expander.Header>
              <TextBlock><ItemsControl ItemsSource="Highlight" /></TextBlock>  
        </Expander.Header>

HB if you want to post it as as an answer I will accept it.

paparazzo
  • 44,497
  • 23
  • 105
  • 176
  • possible duplicate of [Vertical Text in Wpf TextBlock](http://stackoverflow.com/questions/349875/vertical-text-in-wpf-textblock) | `Expander.Header` can be anything (just use [property element syntax](http://msdn.microsoft.com/en-us/library/ms788723.aspx#property_element_syntax)), so this boils down to vertical text. – H.B. Mar 01 '12 at 01:11

1 Answers1

4

Either use property element syntax, as HB notes, or if you'd like to apply the style generically, define a DataTemplate style for your expander, like so :

<Grid.Resources>
  <DataTemplate x:Key="verticalHeader">
    <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Expander}}, Path=Header}" />
  </DataTemplate>

  <Style TargetType="{x:Type Expander}">
    <Setter Property="HeaderTemplate" Value="{StaticResource verticalHeader}"/>
  </Style>
</Grid.Resources>
ianschol
  • 586
  • 2
  • 13