user466722
user466722

Reputation: 15

Context menu in data grid

I want to use context menu in data grid

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.

Upvotes: 0

Views: 816

Answers (2)

Ziad
Ziad

Reputation: 1036

Try this menu instead:

http://sl4popupmenu.codeplex.com

Its more stuffy and simple to use.

Upvotes: 0

TerenceJackson
TerenceJackson

Reputation: 1786

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.

Upvotes: 1

Related Questions