public override void OnBackPressed() { PopupWindow popup = new PopupWindow(); if (fm.BackStackEntryCount < 1) { function += new Function(OnExit); popup.OnAlert("", "Are you sure you want to exit?", function, this); } else { base.OnBackPressed(); } }