Reputation: 389
I will explain what I'm trying to do on following instance:
I have two pages - MainPage.xaml (orientation Portrait) and LandscapeLeft.xaml (orientation LandscapeLeft).
I want to navigate from MainPage.xaml
to LandscapeLeft.xaml
when user rotate phone on Lanscape position.
I've done as follows:
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 phone from PortraitUp to LandscapeLeft position that what happens:
Firstly, content of MainPage.xaml rotates landscape and just then LandscapeLeft.xaml loads.
What I want to do is to eliminate process of content rotation of MainPage.xaml. It doesn't look good and affects performance. Simply, when I rotate the phone I want LandscapeLeft.xaml to be loaded without previous change of content orientation of MainPage.xaml.
Please, any suggestions?
Upvotes: 3
Views: 1070
Reputation: 656
How about putting your contents in a frame. When orientation event fires, change the frame contents instead of navigating to a different page.
...
case PageOrientation.LandscapeLeft:
FrmContents= new LandscapeLeft();
...
This should sort out your performance issues.
Upvotes: 5
Reputation: 66882
From a "user" perspective, I don't think you should use Navigation to achieve this effect.
Navigation is really closely tied to the Back button - so it's not something a user normally expects to also be tied to the device orientation as well.
Things you could probably do are:
I've written apps that support both orientations - they seem to perform really well - what performance issues are you seeing?
Upvotes: 2
Reputation: 65564
Just put all the functionality on one page and then alter what is shown based on the orientation.
Upvotes: 3