简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM