views:

17

answers:

2

i want to use context menu in data gird when i right click on row it is showing the menu when i right click on next row it is not showing i need to left click and again right click

+1  A: 

If you are using the ContextMenu of Silverlight this is a known issue.

If you click the right mouse button,the control sets an overlay. This overlay has an MouseRightButtonDown event handler, but it only closes the context menu.

If you open it here again, it works.

To do that, you have to download the src of the context menu. (http://silverlight.codeplex.com/SourceControl/list/changesets) and "write your own context menu". If you change the src as followed

private void HandleOverlayMouseRightButtonDown(object sender, MouseButtonEventArgs e)
    {
        ClosePopup();
        OpenPopup(e.GetPosition(null));
        e.Handled = true;
    }

the context menu should appear each time you hit MouseRightButtonDown.

This is not the best way, a better approach would be to extend the context menu. But unfortunately all necessary methods are private :(

Hope this helps, I did it that way in my project and it works.

TerenceJackson