我有一個應用程序需要用戶注意,當用戶至少退出一次應用程序。所以我得到下面的代碼來顯示一個消息框。我不知道的是,如果用戶閱讀了該消息,我該如何真正退出該應用?因爲它看起來後面的關鍵事件總是會來到我的設置(OnBackKeyPress)或什麼是一個好方法來處理顯示一個消息框而不會弄亂重寫的BackKey?因爲如果屏幕上出現另一個彈出窗口並且用戶按下了回車鍵,那麼如果我嘗試自己處理backkey,則看起來有些異常。Windows Phone 8:如果按退格鍵,退出應用程序之前如何顯示messagebox?
我的理想情況是應用程序會在他/她按下消息框的退出按鈕時立即關閉。如果按下取消,它將返回而不退出。請幫忙。謝謝!
東西我用......但都不盡如人意
private void OnBackKeyPressed(object sender, CancelEventArgs e)
{
e.Cancel = true;
CheckBox checkBox = new CheckBox()
{
Content = "Do not ask me again",
Margin = new Thickness(0, 14, 0, -2)
};
TiltEffect.SetIsTiltEnabled(checkBox, true);
CustomMessageBox messageBox = new CustomMessageBox()
{
Caption = "Would you like to stop and exit?",
Message =
"If you want to continue listen music while doing other stuff, please use Home key instead of Back key",
Content = checkBox,
LeftButtonContent = "Exit",
RightButtonContent = "Cancel",
};
messageBox.Dismissed += (s1, e1) =>
{
switch (e1.Result)
{
case CustomMessageBoxResult.LeftButton: //Exit
return;// What to do here??
case CustomMessageBoxResult.RightButton: //Cancel
case CustomMessageBoxResult.None:
break;
default:
break;
}
};
messageBox.Show();
}
}
謝謝!所有解決方案都適合我! – thsieh