.NET MAUI Landscape and portraint layouts

Brenden Jacobson 6 Reputation points
2022-07-31T11:57:20.9+00:00

Is it possible to have specific layouts for landscape (typically a Windows app) and portrait (Android/IOS app) pages in .Net MAUI?

I have found that a page that looks good (and usable) on Android becomes totally unusable on Windows.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,411 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 42,001 Reputation points Microsoft Vendor
    2022-08-01T06:20:41.313+00:00

    Hello,

    In MAUI, You could use the OnPlatform mark-up extension to set platform-specific values in XAML.

    For Example, I have a FlexLayout, and I want to show the items horizontally on Windows and vertically on other platforms:

       <FlexLayout Direction="{OnPlatform WinUI=Row, iOS=Column, Android=Column}">  
       ...  
       </FlexLayout>  
    

    If you think it will work for you, you could refer to this official course Platform-specific values in XAML to get more details.

    I've used Onplatform to implement the display effect you show in the text.pdf, you could refer to the following code in the file:

    227166-xmal.txt

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.