有一个弹出页面。当您在侧边菜单打开的情况下旋转屏幕时,菜单本身会关闭。我希望它保持开放。订阅了 IsPresentedChanged 事件。我可以跟踪侧面菜单的状态。据我了解,您需要使用 OnSizeAllocated,但我所有的尝试都失败了。我征求意见。
'''
public class MainPageCS : FlyoutPage
{
MainPage _mainPage;
private bool _isShowing;
public MainPageCS()
{
_mainPage = new MainPage();
Flyout = new SettingsFlyoutPage(this);
Detail = new NavigationPage(_mainPage);
IsPresentedChanged += SetIsPresented;
}
private void SetIsPresented(object sender, EventArgs e)
{
_isShowing = IsPresented;
}
protected override void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);
}
public void OnResumeFlyout()
{
_mainPage.OnResume();
}
}
'''