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
goal : I want to place a text after the submit button using hook_form_alter.
code snippet: xaml <TextBlock Grid.Row=0 Text={Binding Path=NodeType}></TextBlock> <Button Name=bt Grid.Row=1 Click=bt_Click>click</Button> c# public FamilyMemberInfo
I have a small button I want to add to the top left corner
How to place TableLayout a grid of buttons 5 on 5 on the screen
We have place a button on a view. When we press it, nothing happens.
I'm trying to place a button. I have its position set to absolute, so
is it possible to place a button in TabContainer header on the left side
I need to place the label text to left and the radio button to
I am trying to put a JavaFX button in a specific place (specific coordinates)

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.