Reputation: 3
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>
Upvotes: 0
Views: 1219
Reputation: 364
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.
Upvotes: 1
Reputation: 4481
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
Upvotes: 1