Is there a way to attach a context menu in the new 2.0 API/Silverlight 4.0 to a graphic in a graphics layer or the graphics layer itself. It is a dependency object, so it should work, however when I try to add one dynamically, it doesn't do anything. Any help would be appreciated.
Something like:
ContextMenu CM = new ContextMenu();
CM.Items.Add(new MenuItem() { Header = "Test" });
(CM.Items[0] as MenuItem).Click += new RoutedEventHandler(Item_Click);
ContextMenuService.SetContextMenu(GraphicsLayer, CM);
Or:
ContextMenu CM = new ContextMenu();
CM.Items.Add(new MenuItem() { Header = "Test" });
(CM.Items[0] as MenuItem).Click += new RoutedEventHandler(Item_Click);
ContextMenuService.SetContextMenu(GraphicsLayer.Graphics.First(), CM);
Thanks!
Stephen