WPF Popup - when to disable, how to keep in relative position to origin control? ;)
2 simpl questions.
Given a WPF popup...
What is a good way to hide it again when it is used like a submenu? WHich event is proper?
WHat is 开发者_开发百科the way to keep it's position stable relative to the origin control?
THanks in advance ;)
- The
Popup.Opened
andPopup.Closed
events are fired when the popup is shown and hidden. - I would set the
Popup.PlacementRectangle
based on theControl
origin, which can be obtained using theControl.PointToScreen
method like so:
Point location = originControl.PointToScreen(new Point(0, 0));
You will need to listen to the UIElement.LayoutUpdated
event (and probably some other events, too) to determine when the control position has changed.
精彩评论