void ClosePopup(GObject target) { if (target.parent != null) { if (target is Window) ((Window)target).Hide(); else RemoveChild(target); } }