2012-03-01 217 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> 
[垂直文本中的