选择后如何保持上下文菜单打开 [英] How to keep context menu open after selection

查看:130
本文介绍了选择后如何保持上下文菜单打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的上下文菜单有多个菜单项,每个菜单项都包含一个带有选择项的列表框.用户从列表框中选择一个项目后,上下文菜单将关闭.我想强制上下文菜单保持打开状态,以便用户可以移至下一个菜单项并从其列表框中选择.我试过使用contextMenu.StaysOpen = true;menuItem.StaysOpenOnClick;但是,我无法使菜单保持打开状态.

这是我的代码的片段:

My context menu has multiple menu items, each of which contains a listbox with the selections. After the user selects an item from the listbox, the context menu closes. I want to force the context menu to stay open, so the user can move to the next menu item and select from its list box. I''ve tried using contextMenu.StaysOpen = true; and menuItem.StaysOpenOnClick; however, I can''t get the menu to stay open.

Here is a snippet of my code:

contextMenu = new ContextMenu();

enrMenuItem = new MenuItem();
enrMenuItem.StaysOpenOnClick = true;
enrMenuItem.Header = "Enrichment";
enrMenuItem.Items.Add(enrMenuListBox);
contextMenu.Items.Add(enrMenuItem);

gadMenuItem = new MenuItem();
gadMenuItem.StaysOpenOnClick = true;
gadMenuItem.Header = "Gadolinia";
gadMenuItem.Items.Add(gadMenuListBox);
contextMenu.Items.Add(gadMenuItem);

contextMenu.IsOpen = true;

推荐答案

确保您正在使用.net 3.0.否则,只需在显示时存储弹出窗口的位置,并在进行选择(隐藏时选择)后再在存储的位置再次显示它即可.

祝你好运!
Make sure you are using .net 3.0 up. Otherwise, just store the position of the popup when shown and when a selection is made (of when hidden) just show it again at the stored position.

Good luck!


这篇关于选择后如何保持上下文菜单打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆