Try this ... your XAML context menu properties should look like this:
<ElementToWhichContextMenuIsAttached ContextMenu="{StaticResource MyContextMenu}" ContextMenuOpening="MyContextMenuOpening"/>
And your code behind will look like this.
source share