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

  • Home
  • SEARCH
  • 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 3231316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:01:52+00:00 2026-05-17T17:01:52+00:00

When I place Button in grid and add to is’s click action: this.Close(); It’s

  • 0

When I place Button in grid and add to is’s click action:

this.Close();

It’s not working. I want to be able to ask user before exit so I want to use Close(). I don’t want to use Application.Shutdown();
How to solve it.

  • 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-05-17T17:01:52+00:00Added an answer on May 17, 2026 at 5:01 pm

    Just tested it and it works fine! I created a new WPF application and a basic window:

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Button Content="Close" x:Name="closeButton" Click="closeButton_Click" />
        </Grid>
    </Window>
    

    and then added the following to the code-behind

    private void closeButton_Click(object sender, RoutedEventArgs e)
    {
            if (MessageBox.Show("Are you sure?", "Application", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                this.Close();
            }
    }
    

    And it works 100%… Can you post more code to see if something else is wrong? What .NET version are you using, etc…

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

Sidebar

Related Questions

I want to add a popup on click of a Button in WPF. I
I have a small button I want to add to the top left corner
I'm trying to place this menu on the left hand side of the page:
I want to place a Webpart on a page that holds a subfolder of
I have a DataGrid in WPF. And I am trying to add Button s
Tricky one to explain this. I have a custom built properties grid. The left
The other day this code was working. I changed some things and re-ran it
I want to remove the paging buttons on the grid, but I want to
This works (places the button in the overflow area): <ToolBar> <Button ToolBar.OverflowMode=Always>Hit me</Button> </ToolBar>
I have a button on a listview control. I have bound this control to

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.