Context Menu vs Popup

孤者浪人 提交于 2019-12-08 19:16:58

问题


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


回答1:


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).



来源:https://stackoverflow.com/questions/4404731/context-menu-vs-popup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!