I have a ContextMenu, associated to a Canvas
<UserControl>
<Grid myGrid>
<Canvas myCanvas>
<ContextMenu myMenu />...
I clicked on a menuItem entry, and would like to insert at this place a control (label, myLabel).
How should I set the coordinates for myLabel, in order that it corresponds to the mouse rightclick (the ContextMenu actual “location”)?..
You could use the ContextMenu’s TranslatePoint method, e.g. in a MenuItem’s Click event handler, like this:
where myMenu is the ContextMenu:
Here’s how you can get the ContextMenu from the sender of a MenuItem’s Click event: