I got a context menu to work by following this tutorial: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//0001000000v9000000
The interesting thing about the tutorial is that the context menu items are COM objects and they are added to the registry via the EsriRegAsm.exe tool at build time.
I add them programmatically to my context menu at runtime via their GUIDs. I right click my map, then I display a context menu popup, then I select a menu item which is derived from a BaseCommand (here I can't debug into because it is in the COM world), now, according to the tutorial, I am supposed to do some map operations here since I have a IMapControl4 object. But what I really want to do is to pass the control up to my WPF project.
To summarize I would like to call a custom function of mine from the BaseCommand.
I am using ArcEngine 10 in VS2010 with C#.
I found a dumb hack to do it, in the OnClick method, I set the IMapControl4instance.DocumentFilename = "SomeCommand";
Then in my main app, I have an mouse clicked event handler. From the COM object I simulate a mouse move event from within the OnClick() via the user32.dll. Then in my main app the mouseclick event handler checks if mapControl.DocumentFileName is one of my commands, and then sets DocumentFileName to the original value, and executes some operation.
I'm not really proud of this hack, but I'm pleased it works, I'd rather do it the normal way, whatever that is.