Go to another page when changing orientation

I will explain what I am trying to do in the following instance:

I have two pages - MainPage.xaml (orientation portrait) and LandscapeLeft.xaml (LandscapeLeft orientation).

I want to go from MainPage.xamlto LandscapeLeft.xamlwhen the user rotates the phone in the Lanscape position.

I have done the following:

XAML:

   SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"

code behind:

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

When I rotate the phone from PortraitUp to LandscapeLeft, what happens:
Firstly, the contents of MainPage.xaml rotates the landscape, and that's when LandscapeLeft.xaml loads.

, MainPage.xaml. . , , LandscapeLeft.xaml MainPage.xaml.

, - ?

+3
3

. , , .

 ...
         case PageOrientation.LandscapeLeft:
         FrmContents= new LandscapeLeft();
 ...  

.

+5

, , .

+3

, , .

- "" - .

, , :

  • , mainpage.xaml - "" .
  • , , .

, - , , - ?

+2

Source: https://habr.com/ru/post/1794689/


All Articles