In this simple example, I want to show MessageBoxbefore the context menu is displayed.
I am writing this code in "XAML":
<Border>
<Border.ContextMenu>
<ContextMenu ContextMenuOpening="ContextMenu_ContextMenuOpening">
<MenuItem Header="Select pic" IsEnabled="{Binding Path=ProductSelected}" />
<MenuItem Header="Paste pict" Name="miPaste" Click="miPaste_Click"/>
</ContextMenu>
</Border.ContextMenu>
<Image Stretch="Fill" Source="{Binding Path=Product.Picture}" />
</Border>
And I write this in 'CS':
private void ContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
MessageBox.Show("OPPENING");
}
I don’t know why, when I click the right mouse button, the context menu appears, but the MessageBox is never displayed.
source
share