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

  • Home
  • SEARCH
  • 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 6541783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:08:50+00:00 2026-05-25T11:08:50+00:00

Currently i have a strange behavior in my WPF Application. I have a Main

  • 0

Currently i have a strange behavior in my WPF Application.
I have a Main Window and a Settings Dialog. I can show the Settings Dialog, but when i close it, also my Main Window will be closed and the Application quits.

The ShutdownMode of the Application is OnMainWindowClose. But this also happens with OnLastWindowClose.

This is the Code of my Controller class that controls the MainWindow and the Settings Window:

public class MainWindowController : IDisposable, IMainWindowController
{
    private readonly MainWindowViewModel mainWindowViewModel;
    private readonly MainWindow mainWindow;

    private IoAdapter ioAdapter;

    public MainWindowController()
    {
        this.mainWindowViewModel = new MainWindowViewModel(this);
        this.mainWindow = new MainWindow { DataContext = this.mainWindowViewModel };
    }

    public void ShowMainWindow()
    {
        mainWindow.Show();
    }

    public void ShowSettingsWindow()
    {
        var viewModel = new SettingsWindowViewModel();

        var settingsWindow = new SettingsWindow { DataContext = viewModel, Owner = this.mainWindow};

        var showDialog = settingsWindow.ShowDialog();
        if (showDialog != null && showDialog.Value)
        {
            // Apply Settings
        }
    }
  • 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-25T11:08:51+00:00Added an answer on May 25, 2026 at 11:08 am

    you should remove completely your method:

     public void ShowMainWindow()
        {
            mainWindow.Show();
        }
    

    and have the MainWindow displayed as normally in the StartupUri of your App.xaml

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

Sidebar

Related Questions

I have discovered a strange bug with my WPF application and I am trying
I have found an strange behavior when use the open file dialog in c#.
We have a very strange behaviour of a WPF application. Sometimes (not very ofen),
here's another strange behaviour I'm currently facing. I have an application deployed on a
I'm currently writing a Rails app, and hit a somewhat strange quirk. I have
I have a strange issue: I am using SPContext.Current.Web in a .aspx page, but
I currently have an MS Access application that connects to a PostgreSQL database via
I currently have a fairly robust server-side validation system in place, but I'm looking
I currently have heavily multi-threaded server application, and I'm shopping around for a good
I have an strange behavior, which looks lika an problem with (a)synchronous method calls?!?

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.