tags:

views:

181

answers:

1

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

A: 
  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.

Charlie
1 ;) thanks, but I meant which event on the popup to TRIGGER it's hide, not how to hide it. 2 - no ;) That is the INITIAL placement. My problem is when I am moving the original window around, the PopUp... stays in place ;)
TomTom
Ahh.. I have edited my answer to reflect your comments.
Charlie
Got it - acutally my main problem was that I did not close (STayOpen=true) - nce that was changed, everything worked fine ;)
TomTom