WebDucer
WebDucer

Reputation: 1144

Xamarin.Forms NavigationPage and screen rotation

I started Xamarin.Forms and it is great with MVVM pattern.

As main page I use NavigationPage and navigate with PushAsync and PopAsync brteen different pages. This works great if the phone stays in the same orientation. If I rotate screen, Xamarin shows always the first page after rotation.

How can I prevent this? I want to support the screen rotation and don't loose the navigation stack after rotation.

Upvotes: 0

Views: 293

Answers (1)

therealjohn
therealjohn

Reputation: 2398

This is possible when running Android. Make sure that your MainActivity class has the ConfigurationChanges attributes. Here is an example:

[Activity(Label = "MYProject.Droid", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

Upvotes: 1

Related Questions