public void Close <T>() where T : Popup { if (_activePopupStack.IsEmpty() || _activePopupStack.Peek().GetType() != typeof(T)) { return; } Popup popup = _activePopupStack.Get <T>(); OnClosing.SafeInvoke(popup.GetType()); popup.AnimateOut(() => { _activePopupStack.Pop(); PreviousPopup = CurrentPopup; CurrentPopup = null; OnClosed.SafeInvoke(popup.GetType()); popup.Clear(); if (_activePopupStack.Count > 0) { OpenFromStack(); } }); }