2016-11-21 79 views
0

我想將彈出窗口正好居中在屏幕中央。 我已經使用Usercontrol在彈出窗口中顯示。 但是,我計算Horizo​​ntalOffset和垂直偏移的方式是錯誤的。居中彈出窗口/用戶控件

 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;

但爲了工作,彈出應放置在佔據整個屏幕的容器