I have an app that needs to get user's attention when user exit the app at least once. So I get the code below to show a messagebox. What I don't know is how do I really exit the app if user has read the message? Because it seems the back key event will always come to the call I setup (OnBackKeyPress) Or what is a good way to handle showing a messagebox without messing around overriding BackKey? Because if have another pop up on screen and user pressed back key, it seems I got some exception if I tried to handle backkey myself.
My ideal situation is the app will close immediately once s/he pressed my Exit button of the messagebox. If pressed cancel, it will go back without exiting. Please help. Thanks!
Something I used... but not working well
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();
}
}