上下文菜单与弹出菜单

发布于 2024-10-07 02:24:26 字数 61 浏览 0 评论 0原文

ContextMenu 类和 Popup 类有什么区别?

What is the difference between a ContextMenu class and the Popup class?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三月梨花 2024-10-14 02:24:26

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:

Represents a pop-up window that has
content.

The ContextMenu Class:

Represents a pop-up menu that enables
a control to expose functionality that
is specific to the context of the
control.

So the ContextMenu is a more-specific version of a Popup - it's meant to be bound to a specific control, providing ways to interact with that control. Read further on the MSDN page: the ContextMenu has built-in facilities for displaying itself when you right-click on the associated control, and it is automatically displayed within a Popup.

The Popup class is much more general: it simply defines a barebones window (no default borders or decoration) that can display any arbitrary UIElement on top of other controls (notice that the Popup class is part of the Primitives namespace, meaning it's meant to be part of the composition of other controls, such as the ContextMenu).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文