【发布时间】:2012-07-29 00:18:49
【问题描述】:
这就是问题所在。我有一个 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 上(ToolTip 不会出现),而不是悬停在 Label 上(ToolTip 会出现) .
为什么这种行为是正确的以及在这种情况下如何强制ToolTip出现?
【问题讨论】:
标签: wpf xaml tooltip mouseover itemscontrol