为什么在WPF中将项目悬停在透明控件后面时不显示工具提示? 如何让UserControl通过隐形控件显示工具提示?我也试过用矩形代替按钮,结果相同,没有工具提示。
<Grid Height="100" Width="100">
<Rectangle Fill="Red" ToolTip="Tooltip is behind button" Height="20" Width="20" Margin="7,40,73,40"/>
<Rectangle Fill="Yellow" ToolTip="Also behind" Height="20" Width="20" Margin="67,40,13,40"/>
<Button Opacity="0" Background="Transparent" Height="100" Width="100"/>
</Grid>
答案 0 :(得分:1)
为IsHitTestVisible="False"
设置Button
。
用户评论后编辑#1。
我认为你应该这样做:
<Button BorderThickness="0" BorderBrush="Transparent" Background="Transparent" Height="100" Width="100">
<Grid Height="100" Width="100">
<Rectangle Fill="Red" ToolTip="Tooltip is behind button" Height="20" Width="20" Margin="7,40,73,40"/>
<Rectangle Fill="Yellow" ToolTip="Also behind" Height="20" Width="20" Margin="67,40,13,40"/>
</Grid>
</Button>
答案 1 :(得分:0)
设置面板ZIndex以便将元素放在前面:
<Grid Height="100" Width="100">
<Rectangle Panel.ZIndex="2" Fill="Red" ToolTip="Tooltip is behind button" Height="20" Width="20" Margin="7,40,73,40"/>
<Rectangle Panel.ZIndex="1" Fill="Yellow" ToolTip="Also behind" Height="20" Width="20" Margin="67,40,13,40"/>
<Button Panel.ZIndex="0" Opacity="0" Background="Transparent" Height="100" Width="100"/>
</Grid>