2016-11-21 4 views
0

팝업을 화면 중앙에 정확하게 배치하고 싶습니다. 나는 팝업 내에서 표시하기 위해 Usercontrol을 사용했다. 그러나 HorizontalOffset 및 수직 오프셋 계산 방법은 잘못되었습니다.팝업/UserControl 중앙에 넣기

 Popup popUp = new Popup(); 
     ProgressScreen progressScreen = new ProgressScreen(); 
     popUp.Child = progressScreen; 
     //popUp.HorizontalOffset = (this.ActualWidth/2) + (progressScreen.ActualWidth/2); 
     popUp.VerticalOffset = (this.ActualHeight/2) + (progressScreen.ActualHeight/2); 
     popUp.HorizontalOffset = (this.ActualWidth - progressScreen.ActualWidth)/2; 
     popUp.Height = this.ActualHeight; 
     popUp.Width = this.ActualWidth; 
     popUp.IsOpen = true; 

답변

0

나는 일이이

popUp.Placement = System.Windows.Controls.Primitives.PlacementMode.Center;

그러나 팝업을 작동하기 위해

전체 화면을 차지 컨테이너에 배치해야 작동하도록해야