2012-03-01 121 views
3

这个扩张器是垂直的。 的标题显示为Hightlight垂直Epander像垂直头

我想

H 
i 
g 
h 
l 
i 
g 
h 
t 

如何得到它呢?

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

解决的办法是

<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,如果你想发布它作为一个答案,我会接受它。

+0

可能重复Wpf TextBlock](http://stackoverflow.com/questions/349875/vertical-text-in-wpf-textblock)| 'Expander.Header'可以是任何东西(只要使用[property元素语法](http://msdn.microsoft.com/en-us/library/ms788723.aspx#property_element_syntax)),所以这可以归结为垂直文本。 – 2012-03-01 01:11:37

回答

4

要么使用属性元素语法,如HB笔记,或者如果你想一般应用的样式,定义一个DataTemplate风格为您的扩展,像这样:

<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> 
[垂直文本中的