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 6908273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:32:31+00:00 2026-05-27T08:32:31+00:00

I realized when I set the exit button with attribute IsCancel = True, the

  • 0

I realized when I set the exit button with attribute IsCancel = True, the Closing event of window will fire twice.

    private void exitButton_Click(object sender, RoutedEventArgs e)
    {
        // this button was set attribute IsCancel = True.
        Close();          
    }

    private void BaseWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {          
        MessageBox.Show("test"); // this message box will show twice
                                 // when you click on the exit button
        e.Cancel = true;
    }

Is this a bug of WPF ? Is there a workaround ?

Ps : Sorry I forgot to say this bug only occurs when you call your window from a parent window.

  • 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-27T08:32:32+00:00Added an answer on May 27, 2026 at 8:32 am

    I guess I don’t see where this is unexpected behaviour.

    If you designate this as the Cancel button and call .ShowDialog(), then clicking the button will close the window.

    You’ve added your own call to Close() and canceled the close, so both calls are made and the event is raised both times.

    update

    In answer to your comment about why it might behave the way it does, the IsCancel and IsDefault properties provide an easy mechanism to define dialogs using XAML only. They save you the trouble of having to go into the codebehind to define boilerplate click handlers.

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

Sidebar

Related Questions

I have set the line wrapping as 180 and i realized that Eclipse is
hello there is something i've realized with quartz when working.Say a cron is set
I'm troubleshooting a caching issue on a set of secured pages and have realized
I realized that i was using a varchar attribute as a index/key in a
While trying to use Facebook's mobile authentication, I realized that they don't set any
I just realized for my cocoa application I can set the garbage collector setting
im using a videoplayer - and realized that the done button seems to be
I'm trying to figure out how to set the User cannot change password attribute
I have an asp.net application and I've realized, that if I set ValidateRequest to
I realized the solution to this problem while I was creating the documentation 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.