开发者

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


  1. The Popup.Opened and Popup.Closed events are fired when the popup is shown and hidden.
  2. I would set the Popup.PlacementRectangle based on the Control origin, which can be obtained using the Control.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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜