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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:04:16+00:00 2026-06-02T17:04:16+00:00

I am currently working on a WPF application with Caliburn framework. At the top

  • 0

I am currently working on a WPF application with Caliburn framework. At the top right of the application windows, there is a windows CLOSE(X) button. I would like to catch the event for the windows CLOSE button. However, when the application window is closing, the fade out will begin regardless of any buttons which will close the application windows. Also, when the application closes, the application will ask the user whether they want to save the changes or not if there is any changes. However, I can only manage to get the EXIT button in my application to pop up the SAVE CHANGES message and then start the fade out, but this does not occur for the windows CLOSE(X) button. When I pressed the windows CLOSE(X) button, the fadeout will begin first*(Therotically, this shouldn’t happen, it should show the SAVE CHANGES message first and then fadeout afterwards)*. During the fade out, the SAVE CHANGES message appears. At the end, the application crashes because the application cannot close as the message still shows in the application. Does any one know any way to work around this? Below is the code I used for the issue.

The code-behind of the wpf view – I used this to catch the event for WINDOWS CLOSE button:

 protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            if (!closed)
            {
                e.Cancel = true;
                FormFadeOut.Begin();
                closed = true;
            }
            base.OnClosing(e);
        }

This code is used to close the application when the fadeout ends:

private void FormFadeOutAnimation_Completed(object sender, EventArgs e)
{

        this.Close();

}

In my xaml,I used this code in order to call the function to pop up the SAVE CHANGES message when it is closing:

cal:Message.Attach="[Event Closing] = [Action CloseApp2()]"

In my view model, the following function is called by the above xaml code:

  public void CloseApp2()
        {

          //  isClosing = true;
            events.Publish(new IsClosingEvent());
          //  events.Publish(new ClearItemsEvent());
          //  events.Publish(new SwitchTimerOffEvent());
          //  Thread.Sleep(2000);

        }

When the “IsClosingEvent” event is sent, the SAVE CHANGES message will appear if there are any changes made by the user.

Does anyone have any good idea of how to solve this issue?

Thanks for any helps in advance.

Charles

  • 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-02T17:04:18+00:00Added an answer on June 2, 2026 at 5:04 pm

    Use Window.Closing event instead of

    protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a WPF application where I would like to have
I am currently working on an Paint-like WPF application and now stand before the
I'm currently working out the layout of a WPF Application and seem to have
I'm currently working on my first WPF application, and I'm curious as to whether
I am currently working on an application in WPF/C# for personal use. I am
I am currently working on this application(C#,WPF,LINQ2XML,.NET 4.0) that displays details for 'Animals'. An
I am working on an WPF application that uses a BusinessLogic layer (currently a
I am currently working on an MP3 player (in a WPF application) with a
I'm currently working on a WPF application, it's my first so I'm learning as
I'm currently working on a WPF application that uses MVVM. I've got a ListBox

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.