Hello,
Welcome to Microsoft Q&A!
- First select and enable device orientation in each platform .
iOS : https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/device-orientation?tabs=windows#ios
Android : https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/device-orientation?tabs=windows#android
UWP : https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/layouts/device-orientation?tabs=windows#universal-windows-platform
- We can use
OnSizeAllocated
method to react to changes in orientation , the method is called whenever a Page is allocated a new size, which happens whenever the device is rotated. protected override void OnSizeAllocated (double width, double height){
base.OnSizeAllocated (width, height);
if (width != this.width || height != this.height) {
this.width = width;
this.height = height;
if (width > height) {
label.WidthRequest = 400;
} else {
label.WidthRequest = 250;
}
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
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.