1. 程式人生 > >WPF popup被截斷的原因和修改方法

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

framework idm end controls 什麽 main ram ace string

原因: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 }

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