Determining which CustomPopupPlacement was used for WPF Popup

后端 未结 2 1388
生来不讨喜
生来不讨喜 2021-01-16 23:46

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

2条回答
  •  天命终不由人
    2021-01-17 00:20

    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

提交回复
热议问题