Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8996033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:41:58+00:00 2026-06-15T23:41:58+00:00

I have an app that needs to get user’s attention when user exit the

  • 0

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();
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:41:58+00:00Added an answer on June 15, 2026 at 11:41 pm

    If you really need the button to say “Exit” you would have to use either ColinE or Paul Annetts solution. Personally I would try formulating the message in another way and use the normal message box like this:

    protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)
    {
       string caption = "Stop music and exit?";
       string message ="If you want to continue listen music while doing other stuff, please use Home key instead of Back key. Do you still want to exit?";
       e.Cancel = MessageBoxResult.Cancel == MessageBox.Show(message, caption, MessageBoxButton.OKCancel);
    
       base.OnBackKeyPress(e);
    }
    

    This will show a message box but with “Ok” and “Cancel” button instead and will exit directly if user presses “Ok”.

    And for the “Do not ask again”, maybe add a settings on a setting page instead. And add a second dialog the first time the user choose between “Ok” and “Cancel” if he or she wants to see the dialog again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that needs to scan a barcode to get a code
I have an app that I need to get the source code to update
I have a C# app that needs to allow the user to change the
i have a function in a php web app that needs to get periodically
I have an application that needs to hit the ActiveDirectory to get user permission/roles
I have an app that needs to read a PDF file from the file
We have an app that needs to access network resources. It's written in VB.Net.
I have an app that needs to be able use either an sqlite3 datebase
I have an app that needs backgrounds for both parts of the split view.
I have a Rails app that needs to expose values from a database as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.