I\'m trying to figure out which of the passed in array of CustomPopupPlacement
positions have been used when the popup actually renders. Is there any event to d
A better way to find placement of the Popup. This method requires a Child element to be present, but that's no problem considering the Grid that comes with a Popup element.
UIElement container = VisualTreeHelper.GetParent(this) as UIElement;
Point relativeLocation = this.Child.TranslatePoint(new Point(0, 0), container); //It HAS(!!!) to be this.Child
if (relativeLocation.Y < 0) //or use X for left and right
{
Console.WriteLine("TOP PLACEMENT!");
}
else
{
Console.WriteLine("BOTTOM PLACEMENT!");
}
I have a little hacky solution. Save the custom points as fields in the derived TooTip class and override the OnOpened method.
protected override void OnOpened(RoutedEventArgs e)
{
base.OnOpened(e);
var p = this.TranslatePoint(new Point(0, 0), this.PlacementTarget);
var diff1 = this.first - p;
var diff2 = this.second - p;
if (Math.Abs(Math.Min(diff1.Length, diff2.Length) - diff1.Length) < 0.01)
{
// First Point
}
else
{
// Second Point
}
}
Better solutions are welcome