WP7默认创建一个横向或者竖式的显示页面。关于页面的显示有两个属性:
SupportedOrientations="Portrait" Orientation="Portrait" (竖式)
具体看看:
SupportedOrientations有三个可选项
- Portrait (the default)
- Landscape
- PortraitOrLandscape
- Landscape
- LandscapeLeft (tip the phone left)
- LandscapeRight (tip the phone right)
- Portrait
- PortraitDown (normal vertical position)
- PortraitUp (tip the phone upside-down)
从上面的信息不难得出:要使页面适应设备的方向,可以设置SupportedOrientation为PortraitOrLandscape,在OrientationChanged事件设置Orientation来调整显示效果:如图
代码:
代码
代码 using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Controls; namespace WindowsPhoneApp { public partial class LandScape : PhoneApplicationPage { public LandScape() { InitializeComponent(); this.OrientationChanged += new EventHandler
最新评论