Link to home
Start Free TrialLog in
Avatar of axnst2
axnst2Flag for United States of America

asked on

Multiline TabItem Header in WPF

Hi Experts,

          I have a Style defined for my TabItems for a Tab Control under WPF.  How do I need to change my below code to accomplish having multiline TabItem Header's like in the picture:

User generated image
Here's my code.  I have everything I want except the multiline header text:

<Style TargetType="{x:Type TabItem}">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid Width="200" Height="70">
                            <Border Name="Border" Background="Black" BorderBrush="White" BorderThickness="1,1,1,1" CornerRadius="6,6,0,0" >
                                <TextBlock TextWrapping="Wrap"  Height="70" Width="200" VerticalAlignment="Center" TextAlignment="Center" HorizontalAlignment="Stretch" >
                                    <ContentPresenter x:Name="ContentSite" ContentSource="Header" Margin="2,0,0,0"/>
                                </TextBlock>                                
                            </Border>                            
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="Border" Property="Background" Value="#009900" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="False">
                                <Setter TargetName="Border" Property="Background" Value="Black" />
                            </Trigger>
                        </ControlTemplate.Triggers>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>            
        </Style>

Open in new window



Thanks!
SOLUTION
Avatar of Aaron Jabamani
Aaron Jabamani
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are specifying the headers in xaml, you could try using a textblock with a line break.  

 
<TextBlock>FirstLine <LineBreak />Second Line</TextBlock>

Open in new window

Avatar of axnst2

ASKER

For the effort- I don't know all the answers either...