Determining the location of pop-ups relative to the target

How can I determine the placement (PlacementMode) of a Popup control relative to its target after drawing it on the screen? I notice that although I set the placement of my popup to the bottom when there is not enough space left on the screen, it chooses to invert the placement. All this is good and good, provided that there is a way to get an updated placement. So far, checking the placement returns the actual value that I set, and the vertical and horizontal offsets are 0.0.

+4
source share
1 answer

When you install PlacementMode, you suggest where you want the popup to appear in relation to PlacementTarget, PlacementRectangle, or by default it is parent. A pop-up window cannot be displayed off-screen for security reasons.

Link to popup placement:

http://msdn.microsoft.com/en-us/library/bb613596.aspx

If you want to better control how your pop-up screen, when faced with the edge of the screen, can indicate a custom pop-up position.

As described here:

http://msdn.microsoft.com/en-us/library/ms743607.aspx

This allows you to specify the primary offset and alignment, as well as the secondary, if the first is not available. When there is a conflict, he selects a placement that displays the largest part of the popup.

If you really need the coordinates of your popup, this post has a win32 trick that you can use to get the exact location of your popup.

WPP Popup Control - Find X, Y Coordinates

But you should solve most problems with layouts by specifying a custom position.

+2
source

Source: https://habr.com/ru/post/1395303/


All Articles