Rotate an App in the correct mode

Paolo Mossa 246 Reputation points

Hi to all. I have an App with Xamarin that needs to show the screen only in one mode: vertical not orizontal. When I rotate the tablet for me is useful to avoid the rotation in the side when the width is larger than the height so the image of the xaml is not affected because is done for vertical position (up-down not left-right). I need to see only two layouts: up and down when the tablet rotates. In particular for the App is necessary not to show the rotation of 90 degree but only 180 degree in the movement of the tablet.

Sumarizing: I need the Display in only portrait mode regardless the orientation of the tablet

Thanks for any answer

  1. Paolo Mossa 246 Reputation points

    So it is impossible programmatly control the orientation of the XAML?

    I's correct?

  2. Varsha Dundigalla(INFOSYS LIMITED) 5,025 Reputation points Microsoft External Staff

    Thank you for reaching out.

    Yes, that’s correct.

    In Xamarin, you cannot control device orientation from XAML. XAML only lays out the UI after the operating system decides the screen orientation.

    If the screen rotates to landscape, it means Android or iOS is allowing landscape at the platform level. To keep the app vertical only, orientation must be restricted in Android (Activity settings) and iOS (Info.plist).

    So, it’s not that orientation cannot be controlled at all. It simply cannot be controlled programmatically from XAML.


Sign in to comment

Answer accepted by question author

Varsha Dundigalla(INFOSYS LIMITED) 5,025 Reputation points Microsoft External Staff

Thank you for reaching out.

This might be happening because the app is allowing landscape orientation at the platform level, not because of the XAML layout.

In Xamarin apps, XAML does not control screen rotation. XAML only arranges the UI after the operating system has already decided the screen orientation. If the tablet rotates left or right (90° / 270°), it means Android or iOS is allowing landscape mode.

Since the requirement is to keep the app vertical only (normal portrait and upside‑down), and never rotate left or right, this must be handled in the platform configuration, not in the UI layout.

So even if the XAML looks correct, the screen will still rotate because the OS is permitted to enter landscape mode.

To achieve the expected behavior:

  • Allow Portrait and Portrait‑Upside‑Down only
  • Disable Landscape in Android and iOS settings

Once landscape is blocked at the platform level, the app will stay vertical on tablets and will no longer rotate left or right, regardless of how the device is turned.

Please let us know if you require any further assistance, we’re happy to help. If you found this information useful, kindly mark this as "Accept Answer". So that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

  1. Varsha Dundigalla(INFOSYS LIMITED) 5,025 Reputation points Microsoft External Staff

    Thank you for your response. We will now proceed with closure of the thread as per your confirmation. If you encounter any further issues, please feel free to raise a new thread.


Sign in to comment

4 additional answers

  1. Paolo Mossa 246 Reputation points

    now I've solved my problem. to overcame this difficult is sufficent to add this statement in the file MainActivity.cs: ScreenOrientation=ScreenOrientaton.SensorPortrait in the Activity. I thank you for help me. note that are more choiches as Portrait but this is fixed. so happy new year

    1. Varsha Dundigalla(INFOSYS LIMITED) 5,025 Reputation points Microsoft External Staff

      Thanks for confirming. Glad the issue is resolved. Happy New Year!


    Sign in to comment
  2. Paolo Mossa 246 Reputation points

    now I've solved my problem. to overcame this task is sufficent write im MainActivity.cs this statement:

    0 comments No comments

    Sign in to comment
  3. Paolo Mossa 246 Reputation points

    can you suggest me where is located the Ability/Disability Landscape (or Portrait)? I am using Visual Studio 2019. I have not foun the position in the environement

    1. Varsha Dundigalla(INFOSYS LIMITED) 5,025 Reputation points Microsoft External Staff

      Thank you for reaching out.

      In Xamarin you will not find a single global switch in Visual Studio that says “enable / disable Landscape or Portrait”.

      The setting is per platform, and it is in different places:

      Android (Xamarin.Android project) The portrait / landscape permission is not in XAML and not in Visual Studio UI menus. It is controlled in the Android project, specifically in the main Activity configuration (or AndroidManifest). That is why you didn’t find it in the environment screens.

      iOS (Xamarin.iOS project) The option is visible in Visual Studio 2019. Open the iOS project → Info.plist file. There you will find Supported Interface Orientations. This is where you enable or disable Portrait / Portrait Upside Down / Landscape for iPhone and iPad.

      So the reason it feels confusing is:

      • Android → no visible checkbox in VS, orientation is handled at Activity / manifest level
      • iOS → visible in Info.plist editor inside VS

      This is expected Xamarin behavior. Orientation is platform‑specific, not a shared XAML setting.

    2. Paolo Mossa 246 Reputation points

      unfortunately I have not found such command. Nor in Manifest file nor in the PERMISSIONs. I am astonished. Can you give me a way to write in the manifest file instead?

    3. Varsha Dundigalla(INFOSYS LIMITED) 5,025 Reputation points Microsoft External Staff

      Thank you for reaching out.

      could you answer this question for better understanding

      • Are you using Xamarin.Forms with Xamarin.Android / Xamarin.iOS, or a different project type?

    Sign in to comment
  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Sign in to answer

Your answer