0

I have following code:

<Popup AllowsTransparency="True"
       PopupAnimation="Fade"
       Placement="MousePoint" VerticalAlignment="Top" HorizontalAlignment="Center"
       IsOpen="{Binding IsPopupOpen}"
       StaysOpen="True" Margin="50">
       <Label Style="{StaticResource PopupInformationLabelStyle}" 
              Content="{Binding EnumPopupText}" Margin="10,10,10,10" />
</Popup>

This popup displays exactly at the mouse position. Actually I display this popup on DataGridTextColumn editing. So it appears exactly on the textbox when I doubleclick it. So the question is:

Is it possible to add few more pixels to MousePosition? Roughly speaking I need Placement="MousePosition" + 50.

Thanks in advance

3 Answers3

1

Have a look at another similar answer: how to place a popup on a different screen. many of the links there should apply to your problem. You could get the X,Y values and add whatever you need to them.

Specifically: PlacementMode Enumeration has MousePoint. From MSDN on the MousePoint enumeration:

A position of the Popup control relative to the tip of the mouse cursor and at an offset that is defined by the HorizontalOffset and VerticalOffset property values. If a horizontal or vertical screen edge obscures the Popup, it opens in the opposite direction from the obscuring edge. If the opposite screen edge also obscures the Popup, it then aligns with the obscuring screen edge.

Community
  • 1
  • 1
Noctis
  • 11,507
  • 3
  • 43
  • 82
0

Maybe that works..

  Point current = e.GetPosition(this);
  myPopup.HorizontalOffset = current.X + offset;
  myPopup.VerticalOffset = current.Y + offset;
  myPopup.IsOpen = true;
aDoubleSo
  • 1,128
  • 9
  • 19
-4

Set "placement" to "custom" then implement the following in your code:

Popup1.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(placePopup);
dbc
  • 104,963
  • 20
  • 228
  • 340