Don’t have much to say, just can get into the event handler.
XAML:
<Grid>
<Menu IsMainMenu="True" x:Name="x">
<MenuItem Header="_File" />
<MenuItem Header="_Edit" />
<MenuItem Header="_View" />
<MenuItem Header="_Window" />
<MenuItem Header="_Help" />
</Menu>
</Grid>
Code behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
foreach (var item in x.Items)
{
((MenuItem)item).MouseRightButtonDown += MainWindow_MouseRightButtonDown;
}
}
void MainWindow_MouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// Can't get here
}
}
p.s – Same thing with MouseRightButtonUp,MouseLeftButtonDown and MouseLeftButtonUp.
That’s because
MenuItemhandles the event and doesn’t let it propagate. Is there something in particular you need to do? It’s hard to give advice without telling us that. Have you considered using thePreviewMouseRightButtonDownevent instead?