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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:32:38+00:00 2026-06-17T03:32:38+00:00

I have a wpf project which has couple of windows, whne i navigate from

  • 0

I have a wpf project which has couple of windows, whne i navigate from one window to other i just hide one window and create instance of other if not created already, otherwise just make it visible

in all windows there is window closing event handler

 private void Window_Closing_1(object sender, CancelEventArgs e)
    {
         {

        string message = "You are trying to close window " + this.Name + " .Are you sure?";
        string caption = "Exit";
        MessageBoxButton buttons = MessageBoxButton.YesNo;
        MessageBoxImage icon = MessageBoxImage.Question;
        if (MessageBox.Show(message, caption, buttons, icon) == MessageBoxResult.Yes)
        {
            App.Current.Shutdown();

        }
        else
        {
         MessageBox.Show("Closing aborted");

        }
    }

but problem is this event is there in every window so when i close it lots of other prompt from other window which are invisible also show up. Is there a way to avoid other pronpts if i close in only one 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-06-17T03:32:40+00:00Added an answer on June 17, 2026 at 3:32 am

    just create a static method in another class to handle closing of forms.

    public class X 
    {
        private static bool isClosingHandled = false;
    
        public static void HandleClose()
        {
            //// app closing logic
            isClosingHandled = true;
        }
    }
    
    private void Window_Closing_1(object sender, CancelEventArgs e)
    {
        X.HandleClose();   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have WPF userControl Library project. In it I have window which has next
I have a WPF project which compiles just fine. However, when I enable code
I have a wpf project which uses transparent windows and I share this transparent
I have a WPF Project to which i've added a Windows Form. The windows
I Have a Windows Form Project , which has a main form,and in this
I have in my WPF project file RssInfo.cs in which I have public class
I am developing a WPF project in vb.net and have multiple windows in it.
In my WPF project I have a canvas on which I draw an ellipse
I have a standard WPF application. The VS solution has a main project and
I have a WPF application which so far has been client only, but now

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.