Hi everyone,
I've got a scenario where I have a GroupBox which has a bit of content in it. I'm looking to add ContextMenu to that GroupBox and have that menu shown when the user right-clicks anywhere in the box.
The problem I have is that the context menu only appears when the border or the header of the group box is clicked. If you click somewhere inside the box then the context menu of the parent is what's displayed.
Here's some XAML that demonstrates the problem:
<Window x:Class="Dummy.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.ContextMenu>
<ContextMenu>
<MenuItem Header="Window menu" />
</ContextMenu>
</Window.ContextMenu>
<GroupBox Header="GroupBox">
<GroupBox.ContextMenu>
<ContextMenu>
<MenuItem Header="GroupBox menu" />
</ContextMenu>
</GroupBox.ContextMenu>
</GroupBox>
</Window>
So when you click inside the groupbox, you always get the "Window menu" coming up, but I want the "Group menu" instead.
Does anyone know why this is happening and potentially how I go about resolving it?
Many thanks.
OJ