Set SupportedPageOrientation make phone supports horizontal and vertical roll
SupportedPageOrientation="PortraitOrLandscape"
First define rows and columns and elements
<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 methods xaml page
OrientationChanged="Orientation_Lode"