Browse Source

Use pointer position in Popup if can't find target.

If a rooted placement target could not be found, use the current pointer
position as the position of the popup.
pull/486/head
Steven Kirk 11 years ago
parent
commit
9f8d9ed1cb
  1. 10
      src/Perspex.Controls/Primitives/Popup.cs

10
src/Perspex.Controls/Primitives/Popup.cs

@ -276,12 +276,18 @@ namespace Perspex.Controls.Primitives
protected virtual Point GetPosition()
{
var zero = default(Point);
var mode = PlacementMode;
var target = PlacementTarget ?? this.GetVisualParent<Control>();
switch (PlacementMode)
if (target?.GetVisualRoot() == null)
{
mode = PlacementMode.Pointer;
}
switch (mode)
{
case PlacementMode.Pointer:
return MouseDevice.Instance.Position;
return MouseDevice.Instance?.Position ?? default(Point);
case PlacementMode.Bottom:
return target?.PointToScreen(new Point(0, target.Bounds.Height)) ?? zero;

Loading…
Cancel
Save