您可以在后面的代码中设置页面方向
this.Orientation = PageOrientation.Landscape;
请参阅属性http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.phoneapplicationpage.orientation(v=vs.92).aspx
例如:
http ://www.kunal-chowdhury.com/2011/10/know-about-wp7-page-orientation-and.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+kunal2383+%28Kunal%27s+Blog %29
但是,这仅限于设置 Landscape 或 Portrait - 它似乎忽略了 PortraitUp 和 PortraitDown 以及 LandscapeLeft 和 LandscapeRight。
似乎您能做的最好的事情是强制手机进入横向,然后使用旋转变换 - 例如对于全屏页面(没有系统托盘或应用程序栏)然后这可以在左右之间翻转页面景观:
private bool t;
private void Button_Click(object sender, RoutedEventArgs e)
{
SupportedOrientations = SupportedPageOrientation.Landscape;
Orientation = PageOrientation.Landscape;
if (t)
{
t = false;
this.RenderTransform = new RotateTransform() {Angle = 180, CenterX = 400, CenterY = 240};
}
else
{
t = true;
this.RenderTransform = null;
}
}
那是 Xaml:
<phone:PhoneApplicationPage
x:Class="PhoneApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="480"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Landscape"
shell:SystemTray.IsVisible="False">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
<Button Click="Button_Click" Content="one"/>
</StackPanel>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"></Grid>
</Grid>
</phone:PhoneApplicationPage>