Set SupportedPageOrientation make supports de téléphone rouleau horizontal et vertical
SupportedPageOrientation = " PortraitOrLandscape "
Tout d'abord définir des rangées et des colonnes et des éléments
<Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions>
<Image x:Name="Image1" Grid.Row="0" Grid.Column="0" Stretch="Fill" HorizontalAlignment="Center" Source="Img/bdlogo.gif" Height="300" Width="500"/>
<!--TitlePanel 包含应用程序的名称和页标题--> <StackPanel Grid.Row="1" Grid.Column="0" Name="buttonlist" HorizontalAlignment="Center"> <Button Content="按钮1"/> <Button Content="按钮2"/> <Button Content="按钮3"/> <Button Content="按钮4"/> </StackPanel> </Grid>
后台定义 翻滚触发事件
public void Orientation_Lode(object sender, OrientationChangedEventArgs e)
{
if ((e.Orientation & PageOrientation.Portrait) == (PageOrientation.Portrait))
{
Grid.SetRow(buttonlist, 1);
Grid.SetColumn(buttonlist, 0);
}
else
{
Grid.SetRow(buttonlist, 0);
Grid.SetColumn(buttonlist, 1);
}
}
Invoke Page de méthodes
OrientationChanged = "Orientation_Lode"