What is the difference between a ContextMenu
class and the Popup
class?
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
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
).