Click here to Skip to main content
15,914,397 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi!
what I'm trying to do is showing tool tip only on tab name (like in browsers), not on whole tab grid. I've searched Google but i have not found nothing interesting. Any idea how to do that?
Posted
Updated 3-Dec-12 5:15am
v3
Comments
Sanket Panchamia 28-May-13 11:32am    
I have a code that is as follows
<tabitem name="TabItem4">
<tabitem.header>
<textblock text="U2 - Empty" foreground="Black" margin="0,0,0,0" height="20" verticalalignment="Center" name="txtU2" tooltip="testingTip">




I am not getting the tooltip text. Any comments?
Tapirro 28-May-13 12:07pm    
Any error or warnings comming from Visual? For me this solution works perfectly.
Sanket Panchamia 28-May-13 12:29pm    
just no tooltip. Thats it

1 solution

You are likely setting it on the Tab not the header. Try the header instead. This may require you to restyle the header.
You can restyle the header how ever you want though and then set the tooltip for the UI element you use to display the header.

Something like this should work.

Note: this was not tested so there may be errors in it.

XML
<TabControl x:Name="tabCtrlMain" ItemsSource="{Binding Items}" >
        <TabControl.Resources>
            <Style TargetType="TabItem">
                <Setter Property="Header" Value="{Binding FileName}" />
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate DataType="{x:Type TabItem}">
                            <Border x:Name="grid">
                                    <ContentPresenter>
                                        <ContentPresenter.Content>
                                            <TextBlock Text="{TemplateBinding Content}" Tooltip="{Binding Path=TooltInfo}"/>
                                        </ContentPresenter.Content>
                                    </ContentPresenter>
                                </Border>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </TabControl.Resources>
    </TabControl>


If you are directly adding tabs in XAML then just code right to the header.

i.e.

XML
<TabItem>
    <TabItem.Header>
        <Grid>
            <Grid.ToolTip>
                <!--Place your tooltip content here-->
            </Grid.ToolTip>

        </Grid>
    </TabItem.Header>

</TabItem>
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900