上下文菜单与弹出菜单
ContextMenu
类和 Popup
类有什么区别?
What is the difference between a ContextMenu
class and the Popup
class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
ContextMenu
类和 Popup
类有什么区别?
What is the difference between a ContextMenu
class and the Popup
class?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
MSDN 文档很好地显示了区别:
弹出 类:
ContextMenu 类:
因此,ContextMenu 是 Popup 的更具体版本 - 它旨在绑定到特定控件,提供与该控件交互的方法。在 MSDN 页面上进一步阅读:
ContextMenu
具有内置功能,可以在您右键单击关联的控件时显示自身,并且它会自动显示在内 >弹出窗口
。Popup
类更为通用:它只是定义了一个准系统窗口(没有默认边框或装饰),可以在其他控件之上显示任意UIElement
(请注意,Popup
类是 Primitives 命名空间,这意味着它是其他控件组合的一部分,例如ContextMenu
)。The MSDN docs do a nice job of displaying the distinction:
The Popup Class:
The ContextMenu Class:
So the
ContextMenu
is a more-specific version of aPopup
- it's meant to be bound to a specific control, providing ways to interact with that control. Read further on the MSDN page: theContextMenu
has built-in facilities for displaying itself when you right-click on the associated control, and it is automatically displayed within aPopup
.The
Popup
class is much more general: it simply defines a barebones window (no default borders or decoration) that can display any arbitraryUIElement
on top of other controls (notice that thePopup
class is part of the Primitives namespace, meaning it's meant to be part of the composition of other controls, such as theContextMenu
).