How to change the orientation in .NET MAUI



    Currently, MAUI doesn't provide a cross-platform property to change the orientation, but you can write your own code to access the native APIs.

    Here's how can you change the orientation in .NET MAUI:

    On Android:

    On iOS:

    There are two scenarios you may encounter in your business logic:

    The first one is that you want to change the orientation in the current screen. Here's the code:

    The second one, you want to change the orientation while opening the landscape page or vice versa.

    See the following code below:

    After that, in Appdelegate.cs add an export method named GetSupportedInterfaceOrientations. This method will be fired when a page is appearing, it's used to set the orientation supported by the app.

    Remember SetOrientation() before navigating to another page. 

    You can refer to invoke-platform-code to write cross-platform code.

    That's all for change the orientation in NET MAUI. I hope this would be helpful for some of you.