The behavior I want is this: when the popup is opened, it should be opened so that the mouse point is within a 5 px margin of the edge of the popup. My current code is this:
productCategoryPopup.Placement = PlacementMode.MousePoint;
productCategoryPopup.VerticalOffset = -5;
productCategoryPopup.HorizontalOffset = -5;
and
<Popup x:Name="productCategoryPopup" IsOpen="False" StaysOpen="False" AllowsTransparency="True">...</popup>
This works as long as the popup isn't automatically displaced, which it is in the case where the content is too long to fit on the screen, if the top-left corner is at the mousepoint. So my offset, which was added to ensure that the mouse if inside, with a margin, now makes the popup open outside. This in turn immediately closes the popup, which I assume is due to the fact that my mouseup lands outside the popup.
To clarify, what happens when i open a popup near the bottom of the screen is that the popup opens such that it's bottom left corner is 5 pixels above (-5) and to the left of the mousepoint, it then closes if I release the mouse button.
What is the best way of achieving the above stated behavior?
