控件不响应鼠标操作,因为它位于视图层次结构的底部

Control doesnt respond to mouse actions because it's on bottom of view hierarchy

我有一个带有以下 DataTemplate 的 ContentControl

xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
....
<DataTemplate DataType="{x:Type y:DataGraph}">
                <Grid>
                    <!--Because PlotView is under Label it doesnt respond to mouse actions (click, zoom, etc)-->
                    <oxy:PlotView  Model="{Binding PlotViewModel}"/>
                    <!--Want Label to be displayed on top-->
                    <Label Content="some text"/>
                </Grid>
            </DataTemplate>

我希望在 oxy:PlotView 上方显示一些文本,但如果我这样做,oxy:PlotView 会停止响应鼠标操作(缩放、单击等)。

如何显示悬停在另一个控件上的标签,但让底部控件保持对鼠标操作的响应?

尝试将 Label 的 IsHitTestVisible 属性 设置为 False。然后鼠标点击将直接通过它。

如果您想知道点击的位置,请启动 Snoop,附加到您的 window,打开“事件”选项卡,点击您程序中的内容,然后查看您的事件发生了什么回到 Snoop。