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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:41:51+00:00 2026-06-12T13:41:51+00:00

Possible Duplicate: Notification when WPF UI closes I have asked a very similar question

  • 0

Possible Duplicate:
Notification when WPF UI closes

I have asked a very similar question before, but i did not get any usable response. I am hoping that someone out there might be able to help me.

I have an existing tray app programmed as a Windows Form app.
I have an existing Settings form programmed as WPF.

The Tray App needs to be able to:
* Open the Settings App n times, with only one instance ever opened at a time
* Receive notification when the user closes the Settings App.

The Settings App uses a ResourceDictionary, which I believe means it must be started from App.xaml.

I can get the Settings window to open once and notify the Tray when it is shut down using the following code, but I cannot get it to open again.

        if (gui == null)
        {
            //shell = new mainWindow();
            //shell.CloseEvent += settings_FormClosed;

            gui = new App();
            //gui.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            gui.MainWindow = shell;
            gui.InitializeComponent();
            //gui.Run();
            gui.Exit += new System.Windows.ExitEventHandler(settings_FormClosed);

            IsUIOpen = true;
        }

If I uncomment the lines above, I can then intercept the close event, and set the Visibility to Hidden. The next time the user selects Settings, I can set it back to Visible. However, the first time Settings opens, it will not trigger the Exit event and shell is not getting all the ReferenceDictionary (or losing access to it), so the window is not displaying properly.

Is there a way to run WPF from the app, and access MainWindow (which often seems to be null, and is not of the type of my own window) so a custom listener can be added to mainWindow?

Alternately, is there a way to dispose of the static App so I can re-instantiate it the next time the user clicks on Settings.

I know there must be some way to get WPF to play nice with Win Forms. Thank you to everyone who attempts to help. This has been giving me major headaches.

  • 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-12T13:41:52+00:00Added an answer on June 12, 2026 at 1:41 pm

    Since your settings is an app, I would use the System.Diagnostics.Process from within your Winforms app to start your WPF settings app. Since you are starting the Settings as an application rather than trying to invoke it as a Window, your styles will be loaded. Also, you can use the WaitForExit() or WaitForExit(int) methods of Process to wait for your settings app to finish, relinquishing control back to your Winforms app only when the Settings app is complete. This also serves as the notification requested when the Settings app is closed.

    Here’s a quick code snippit:

    IN EVENT THAT OPENS SETTINGS WPF APP:

    Process myProcess = new Process();
    myProcess.StartInfo.UseShellExecute = false;
    myProcess.StartInfo.FileName = "C:\\mysettingsapp\\mysettingsapp.exe"; // replace with path to your settings app
    myProcess.StartInfo.CreateNoWindow = false;
    myProcess.Start();
    // the process is started, now wait for it to finish
    myProcess.WaitForExit();  // use WaitForExit(int) to establish a timeout
    

    By calling WaitForExit on the main thread, the WinForms app is blocked waiting for the settings app to complete. This will prevent users from opening more than one settings window. I didn’t see a non-blocking requirement for the Winforms app. So if you can’t block, I can come up with another way.

    UPDATE
    To grab the executing assembly’s path:

      string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why does the binding update without implementing INotifyPropertyChanged? I have WPF: <TextBlock
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: ios5 new Notification Center issue Many apps have established a paradigm like
Possible Duplicate: Displaying a Toast notification in Android framework I have an activity and
Possible Duplicate: Trying to get tables next to each other horizontal I have two
Possible Duplicate: Push-Notification Badge auto increment. I have implemented Push Notification for my iPhone
Possible Duplicate: How to set Local Notification repeat interval to custom time interval? I
Possible Duplicate: javascript: pause setTimeout(); Im using jQuery and working on a notification system
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Change Notification with Sql Server 2008 Am just wondering is there's anyway

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.