2012-05-29 56 views

回答

3

您可以獲取根目錄的當前大小並獲取值。 記住,如果你對你的RootVisual具有控制,做了正確的投

Dim PrincipalObject = CType(Application.Current.RootVisual, System.Windows.UIElement) 

Dim posY = (PrincipalObject.RenderSize.Height/2) - (popup.Height/2) 
Dim PosX = (PrincipalObject.RenderSize.Width/2) - (popup.Width/2) 

C#應該是..

System.Windows.UIElement PrincipalObject = (System.Windows.UIElement) Application.Current.RootVisual; 
Double posY = (PrincipalObject.RenderSize.Height/2) - (popup.Height /2) 
Double posX = (PrincipalObject.RenderSize.Width/2) - (popup.Width /2) 
+0

庵在C#中嗎? – maehue

+0

完成!請記住,如果你對你的RootVisual有控制權,那就做適當的演員 –

相關問題