0

I've seen this link to solve my problem, but it wasn't work for me, because, I have two grids in my Layout and I need tha one of them get the mouse event and the other no. The first grid is like a title bar with buttons and where I can move my window. Does anyone have any solutions or suggestions?

My Xaml

 <UserControl ...>
    <Grid>
        <Grid.RowDefinitions>
           <RowDefinition Height="Auto"/>
           <RowDefinition Height="*"/>
       </Grid.RowDefinitions>

       <Grid Grid.Row="0">

             ....

        </Grid>

        <Grid Grid.Row="1" 
              behaviors:PopupBehavior.IsPopupEventTransparent="True">

              .....

        </Grid>
   </Grid></UserControl>
Maycon
  • 3
  • 3

2 Answers2

1

If you want to ignore mouse input on any WPF UI Element, you might just set its IsHitTestVisible property to false.

Example:

<Grid>
  <Button Click="OnButtonClick" Content="The Button" />
  <Border Background="Red" Opacity="0.5" IsHitTestVisible="False" />
</Grid>

The red semi-transparent border will be displayed in front of the button. Still, the button will receive click events, because the hit test is disabled for the border.

Further reading: MSDN

Frank
  • 4,461
  • 13
  • 28
  • Thank you, but I need that the mouse events to pass through my UserControl too, but just in this grid. – Maycon Sep 18 '17 at 18:55
1

If you set the IsHitTestVisible property to false on a root element you cant set it to true on any of its children. As you can see this question never got an answer How can you set IsHitTestVisible to True on a child of something where it's set to false?.

So you can forget to have a pass-through UserControl with HitTestVisible children.

babgev
  • 344
  • 2
  • 8