开发者

Context menu in data grid

I want to use conte开发者_如何学Cxt 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.


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.


Try this menu instead:

http://sl4popupmenu.codeplex.com

Its more stuffy and simple to use.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜