TabItem上的工具提示:在标题上显示,但不在内容上显示

axe*_*ide 9 wpf xaml tabcontrol tooltip tabitem

TabControl的TabItems上的工具提示不仅在TabItem的标题上产生,而且还在任何未明确设置其自己的工具提示的TabItem内容上产生.

这是一个例子,它重现了这个问题:

<Window x:Class="TestToolTipsOnTabControl.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow">
    <Grid>
        <TabControl>
            <TabItem Header="Tab1"
                     ToolTip="Tooltip of tab1">
                <StackPanel>
                    <TextBlock Text="Content of tab1 with its own tooltip" 
                               ToolTip="Tooltip on content of tab1"/>
                    <TextBlock Text="more content of tab1" />
                </StackPanel>
            </TabItem>
            <TabItem Header="Tab2"
                     ToolTipService.ToolTip="Tooltip of tab2">
                <StackPanel>
                    <TextBlock Text="Content of tab2 with its own tooltip"
                               ToolTipService.ToolTip="Tooltip on content of tab2"/>
                    <TextBlock Text="more content of tab2" />
                </StackPanel>
            </TabItem>
            <TabItem Header="Tab3">
                <StackPanel>
                    <TextBlock Text="Content of tab3" />
                    <TextBlock Text="more content of tab3" />
                </StackPanel>
            </TabItem>
        </TabControl>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

将鼠标指针移动到"tab1的更多内容"文本上将显示我想显示在TabItem标题上的工具提示.

有没有办法让ToolTip只显示在TabItem标题上,但是没有其他地方?

Bol*_*olu 9

有没有办法让ToolTip只显示在TabItem标题上,但是没有其他地方?

你应该只申请TooltipHeader不是全部,TabItem所以改为:

           <TabItem>
                <TabItem.Header>
                    <TextBlock Text="Tab1" 
                     ToolTip="Tooltip of tab1"/>
                </TabItem.Header>
                <StackPanel>
                    <TextBlock Text="Content of tab1 with its own tooltip" 
                               ToolTip="Tooltip on content of tab1"/>
                    <TextBlock Text="more content of tab1" />
                </StackPanel>
            </TabItem>
Run Code Online (Sandbox Code Playgroud)