WPF popup被截断的原因和修改方法

原因:wpf里 popup不能超过屏幕75%的面积,不知道为什么要这么设置?

修改方法:

 1 private void SetPopupScreen()
 2         {
 3             Rect rtWnd = new Rect(0, 0, gridMainArea.ActualWidth, gridMainArea.ActualHeight);
 4             DependencyObject parent = popPatientInfos.Child;
 5             do
 6             {
 7                 parent = VisualTreeHelper.GetParent(parent);
 8                 if (parent != null && parent.ToString() == "System.Windows.Controls.Primitives.PopupRoot")
 9                 {
10                     var element = parent as FrameworkElement;
11                     element.Width = gridMainArea.ActualWidth;//根据需要修改宽高
12                     element.Height = gridMainArea.ActualHeight;
13                     rtWnd = new Rect(0, 0, element.Width, element.Height);
14                     popPatientInfos.PlacementRectangle = rtWnd;
15                     break;
16                 }
17             }
18             while (parent != null);
19         }
原文地址:https://www.cnblogs.com/fengbol/p/9342553.html