You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WPF背景图片ToolTip被上层ListBox遮挡的问题求助

WPF背景图片ToolTip被上层ListBox遮挡的问题求助

我最近在做一个功能,想在背景图片上标记一些位置,所以用了Grid布局把Image和ListBox叠在一起——ListBox的ItemsPanel用的是Canvas,这样能自由定位每个标记项。我的XAML代码大概是这样的:

<Grid>
    <Image Source="{Binding ImageSource}"
           ToolTipService.ToolTip="{Binding ImageToolTip}" />

    <ListBox ItemsSource="{Binding ListSource}"
             Background="Transparent">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas IsItemsHost="True" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemContainerStyle>
            <Style TargetType="{x:Type ListBoxItem}">
                <Setter Property="Canvas.Left" Value="{Binding Left}" />
                <Setter Property="Canvas.Top" Value="{Binding Top}" />
                <Setter Property="Padding" Va...
            </Style>
        </ListBox.ItemContainerStyle>
    </ListBox>
</Grid>

现在遇到个麻烦:背景Image的ToolTip会被上层的ListBox给挡住,鼠标移到图片区域的时候,ToolTip根本没法正常显示出来。有没有大佬能帮忙看看怎么解决这个问题呀?

备注:内容来源于stack exchange,提问作者Nostromo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.16 08:24:31