我在我的 xamarin 应用程序中使用 RgPlugn PopUp 页面,我想检查此弹出页面是否打开,因为当会话时间结束时我将用户从应用程序中踢出。如果没有 RgPlugn PopUp 页面,则会出现 null 异常错误。 如何检查 RgPlugn PopUp 页面是否为空?我使用此代码来踢出用户。
private void RedirectAndInformInactivity()
{
Device.BeginInvokeOnMainThread(async () =>
{
await Application.Current.MainPage.DisplayAlert("Oturum Sonlandı!", "İşlem yapmadığınız için oturumunuz sonlandırılıyor!", "Tamam");
await PopupNavigation.Instance.PopAsync();
await Application.Current.MainPage.Navigation.PushAsync(new LogoutPage());
});
}
您可以检查是否有弹窗打开。
//Verifying whether any popup pages are present in the PopupStack
//It returns true if there are any pop-up pages in the PopupStack.
if (Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.Any())
{
List<PopupPage> popupPageList = new List<PopupPage>();
popupPageList = Rg.Plugins.Popup.Services.PopupNavigation.Instance.PopupStack.ToList();
// popupPageList contains all of the pages that are present in the PopupStack, which you can validate according to your requirements.
}
else
{
//Popup stack is empty
}