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
}
}