单击时不会关闭的 WPF 菜单项 [英] WPF menu item that doesn't close when clicked
问题描述
是否可以制作一个 WPF 菜单项,在单击时不会关闭下拉菜单?
Is it possible to make a WPF menu item that, when clicked, does not close the dropdown menu?
想象一个首选项菜单,其中有几个复选框样式的首选项设置作为菜单项.我希望能够在关闭菜单之前切换其中的几个.
Imagine a Preferences menu, with several checkbox-style preference settings as menu items. I want the ability to toggle several of them before closing the menu.
澄清:这仅适用于某些菜单项,在某些菜单中.File > Open 应该仍然关闭菜单,就像用户期望的那样.即使有非关闭"项目的菜单也可能有关闭"项目.我正在寻找每个项目的粒度.
CLARIFICATION: This is only for some menu items, in some menus. File > Open should still close the menu, just like the user expects. Even the menu that has "non-closing" items will likely have "closing" items as well. I'm looking for per-item granularity.
推荐答案
MenuItem
有一个名为 StaysOpenOnClick
的属性,它似乎是您正在寻找的内容
MenuItem
has a Property called StaysOpenOnClick
which seems to be what you're looking for
因此,要阻止 MenuItem 在单击时关闭 Menu
/ContextMenu
So, to stop MenuItem from closing Menu
/ContextMenu
on click
<MenuItem Header="MenuItem That Doesn't Close On Click"
StaysOpenOnClick="True"
.../>
这篇关于单击时不会关闭的 WPF 菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!