2012-07-31 77 views
1

问题出在这里。我有一个ItemsControl,并且我想要显示一个工具提示如果用户将鼠标悬停在ItemsControl。看起来很简单,对吧?为什么ItemsControl.ToolTip只有在鼠标悬停在其项目上时才可见

下面的例子:

<ItemsControl BorderBrush="Blue" BorderThickness="1"> 
    <ItemsControl.ToolTip> 
     <ToolTip Content="Text" /> 
    </ItemsControl.ToolTip> 
    <ItemsControl.ItemsPanel> 
     <ItemsPanelTemplate> 
      <WrapPanel /> 
     </ItemsPanelTemplate> 
    </ItemsControl.ItemsPanel> 
    <Label BorderBrush="Red" BorderThickness="1">One</Label> 
    <Label BorderBrush="Red" BorderThickness="1">Two</Label> 
    <Label BorderBrush="Red" BorderThickness="1">Three</Label> 
    <Label BorderBrush="Red" BorderThickness="1">Four</Label> 
    <Label BorderBrush="Red" BorderThickness="1">Five</Label> 
    <Label BorderBrush="Red" BorderThickness="1">Six</Label> 
    <Label BorderBrush="Red" BorderThickness="1">Seven</Label> 
</ItemsControl> 

制作窗宽足够小,让WrapPanel包装的物品。并尝试将鼠标悬停在ItemsControl的工具提示不会出现),比悬停在标签工具提示就会出现)。

为什么这种行为是正确的,在这种情况下如何强制工具提示出现?

回答

5

ToolTip对于ItemsControl在任何情况下都不会显示,直到您给出Background a Brush

<ItemsControl Background="Transparent" 
+0

你是摇滚乐!谢谢! – stukselbax 2012-07-31 09:11:56

+0

我有一个悬停在ItemsControl中的网格类似的问题。看起来,除非您在控件上设置背景,否则如果您不在子元素上方,则鼠标悬停会落空。 – 2015-12-09 20:13:30

相关问题