简体   繁体   中英

Centering an App in WP7

I've chosen Landscape only for my view in 800w x 480h available space. I want my app to be 600 (w) by 240 (h), absolutely sized. (There is a long story as to why this is, but it ain't gonna change - I don't want or need to fill all of the available space and need absolute sizing) .

How can I center the app horizontally and vertically so that is its CenterX/Y is the same as the available space's CenterX/Y. I've tried VerticalAlignment="Center" HorizontalAlignment="Center" on both <phone:PhoneApplicationPage/> as well as <Grid/> and <Canvas/> tags - none of this works. Any thoughts on how I be able to center my app on screen?

You could try with margins on the main grid:

Margin="100,120"

100 = (800-600)/2

120 = (480-240)/2

为什么不使用网格,并在其中将Width =“ 600”和Height =“ 240”的网格嵌套在其中,将Horizo​​ntalAlign =“ Center”和VerticalAlign设置为对应的网格呢?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM