I am using Xamarin tool kit pop up in my Xamarin app iOS. It works fine in portrait mode. If I change the orientation to landscape mode while the pop up is already opened, the pop up does not show in the center of the screen. It shows on the left corner of the screen. It works well in android but in iOS it shows on left corner on screen rotation.
Below is my pop up code.
<?xml version="1.0" encoding="utf-8" ?>
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit"
Size="360,200"
IsLightDismissEnabled="False"
x:Class="Mobile.NewPopup">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" >
<Label Text="Sample PopUp"/>
</StackLayout>
</xct:Popup>
I am calling like this from the button click of my page.
await App.Current.MainPage.Navigation.ShowPopupAsync(new NewPopup();
In portrait mode it is opening in the center of the screen.
How can I move this the pop up to the center of the screen while in landscape mode?
When opening your popup subscribe to the Application.Current.MainPage.SizeChanged event to get notified when the screen rotates between Portrait and Landscape.
And then manually fire the PropertyChanged event for the VerticalOptions or HorizontalOptions property of the popup via OnPropertyChanged. This will force the PopupRenderer to recenter the popup.