方向更改时导航到另一个页面

Mak*_*aku 3 c# windows-phone-7

我将解释我在以下实例上要做的事情:

我有两个页面 - MainPage.xaml(orientation Portrait)和LandscapeLeft.xaml(orientationLeft方向).

我想导航MainPage.xamlLandscapeLeft.xaml用户在Lanscape位置旋转手机时.

我做了如下:

XAML:

   SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
Run Code Online (Sandbox Code Playgroud)

代码背后:

   protected override void OnOrientationChanged(OrientationChangedEventArgs e)
   {
       switch (e.Orientation)
       {
           case PageOrientation.LandscapeLeft:
               NavigationService.Navigate(new Uri("/LandscapeLeft.xaml", UriKind.RelativeOrAbsolute));
               break;
       }
       base.OnOrientationChanged(e);
   }
Run Code Online (Sandbox Code Playgroud)

当我将手机从PortraitUp旋转到LandscapeLeft位置时会发生以下情况:
首先,MainPage.xaml的内容会旋转横向,然后加载LandscapeLeft.xaml.

我想要做的是消除MainPage.xaml的内容轮换过程.它看起来不太好并影响性能.简单地说,当我旋转手机时,我想要加载LandscapeLeft.xaml而不事先更改MainPage.xaml的内容方向.

请问有什么建议吗?

Joh*_*les 5

如何将您的内容放在框架中.触发方向事件时,更改帧内容而不是导航到其他页面.

 ...
         case PageOrientation.LandscapeLeft:
         FrmContents= new LandscapeLeft();
 ...  
Run Code Online (Sandbox Code Playgroud)

这应该解决您的性能问题.