Browse Source

Fix popup placement.

pull/58/head
Steven Kirk 11 years ago
parent
commit
15cbcdc648
  1. 26
      Perspex.Controls/Popup.cs

26
Perspex.Controls/Popup.cs

@ -296,23 +296,23 @@ namespace Perspex.Controls
/// <returns>The popup's position in screen coordinates.</returns> /// <returns>The popup's position in screen coordinates.</returns>
private Point GetPosition() private Point GetPosition()
{ {
var target = this.PlacementTarget ?? this.GetVisualParent<Control>(); var target = this.PlacementTarget ?? this.GetVisualParent<Control>();
Point point; Point point;
switch (this.PlacementMode)
{
case PlacementMode.Bottom:
point = target.Bounds.BottomLeft;
break;
case PlacementMode.Right:
point = target.Bounds.TopRight;
break;
default:
throw new InvalidOperationException("Invalid value for Popup.PlacementMode");
}
if (target != null) if (target != null)
{ {
switch (this.PlacementMode)
{
case PlacementMode.Bottom:
point = new Point(0, target.Bounds.Height);
break;
case PlacementMode.Right:
point = new Point(target.Bounds.Width, 0);
break;
default:
throw new InvalidOperationException("Invalid value for Popup.PlacementMode");
}
return target.PointToScreen(point); return target.PointToScreen(point);
} }
else else

Loading…
Cancel
Save