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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:40:40+00:00 2026-05-23T20:40:40+00:00

As the title states, I’m calling a WPF form from a WinForm app, (with

  • 0

As the title states, I’m calling a WPF form from a WinForm app, (with several classes on the call stack between) numerous times. Initially, the WPF only worked once. After some googling, I found that I had to add ShutdownMode.OnExplicitShutdown to the WPF application create.

Now, after adding that, upon exiting the first WPF form, control never returns from the ‘Run’ call and focus is given back to the WinForm dialog. If I exit that, I finally get control returned from the WPF run.

Winform:

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MainForm form = new MainForm();
Application.Run(form);

WPF pre-init:

application = new System.Windows.Application
{
    ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown
};

Calling the WPF form:

ConfirmForm form = new ConfirmForm();
application.Run(form);

What is going on here?:

  • 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-23T20:40:41+00:00Added an answer on May 23, 2026 at 8:40 pm

    Application.Run (in both WinForms and WPF) is a blocking call that runs the message loop and returns when the application is ready to exit.

    You should just call Show(), which shows the Form or Window and returns immediately.

    However, you will need to call ElementHost.EnableModelessKeyboardInterop to tell WPF to use the WinForms message loop.

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

Sidebar

Related Questions

As the title states my Ajax call is actually causing the form to be
As the title states, is there a way to prevent extra elements from showing
As the title states the app that I am developing has an issue that
As the title states, I have a C# console app which uses interop to
As the title states, I can connect to another machine from my server via
As the title states, I made an Ajax call to a .html file which
Pretty much as the title states, I'm grabbing some values from a Db, which
My post title almost states it all: How do I download a file from
As the title states, I want to get the difference (in seconds) between 2
As title states, my piece of code which was from an example provided by

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.