控件不响应鼠标操作,因为它位于视图层次结构的底部(Control doesnt respond to mouse actions because it's on bottom of view

编程入门 行业动态 更新时间:2024-10-25 08:18:22
控件不响应鼠标操作,因为它位于视图层次结构的底部(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会停止响应鼠标操作(缩放,单击等)。

如何显示悬停另一个控件的标签,但是底部控件是否仍然响应鼠标操作?

I have a ContentControl with following DataTemplate

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>

I want some text to be displayed on top of oxy:PlotView, but if I do so, oxy:PlotView stops to respond to mouse actions (zoom, click etc).

How can I show label hovering another control, but make bottom control remain responding to mouse actions?

最满意答案

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

如果您想知道点击的去向,那么启动Snoop,附加到您的窗口,打开Events选项卡,单击程序中的内容,然后在Snoop中查看您的事件发生了什么。

Try setting the IsHitTestVisible property of the Label to False. Mouse clicks will then pass straight through it.

If you're ever wondering where the clicks are going then fire up Snoop, attach to your window, open the Events tab, click on the thing in your program, then see what happened to your event back in Snoop.

更多推荐

本文发布于:2023-07-05 07:51:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034862.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:鼠标   因为它   视图   控件   层次

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!