Determining the CustomPopupPlacement used for WPF Popup

advertisements

Am 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 detect this?

This msdn thread from 2009 seems to be exactly my issue however there does not seem to be an answer for it.

http://social.msdn.microsoft.com/Forums/da/wpf/thread/4c6d216a-0011-4202-aa7e-2fccef3cc355

The marked answer is wrong and my situation is exactly as the OP in the thread.

I'm going to have my popup with 4 paths and use a DP to toggle visibility on three paths to choose the correct arrow path being rendered.

So given we provide 4 placement options via the CustomPopupPlacementCallbackdelegate, Is there a way to detect which of the 4 positions the system finally chose after dealing with screen edge cases and the sorts.


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