This is exactly what I want/need to do. I have one twist however you may be able to help me with, adding a MenuItem:
and to your hosting UserControl:
The problem is that if you right click, all works well, if you left click (on first time run), the List menu item is not populated. I can't figure out why but it seems the binding is not updated until you right click.
I'm having an absolutely awful time getting this to work. I followed your lead and tried PlacementTarget, but that didn't help. When I left-click my Image (note I'm doing this on MouseLeftButtonDown) and call contextMenu.IsOpen = true, nothing appears at all. Worse, the left mouse button is now dead unless I click elsewhere and do other things until it starts working again.Right-click works perfectly, and if I left-click while the menu is already open from a right-click it works fine too.Note I am populating the menu manually on ContextMenuOpening event, which isn't seeming to be called when I set IsOpen to true, but even if I populate the menu manually before setting that, still nothing appears!Update: Lame! I changed the event to PREVIEWMouseLeftButtonDown and now it works. Sheesh.
- Edited by chaiguy1337 Tuesday, October 28, 2008 7:35 PM