I have a wpf application with a button, which opens a new Window, where I want to determine some settings. See following code:
public partial class MainWindow : Window { private SettingsWindow SettingsWindow; public MainWindow() { InitializeComponent(); } private void settings_Click(object sender, RoutedEventArgs e) { if (this.SettingsWindow == null) { SettingsWindow = new SettingsWindow(); // No reentrace here !!! } SettingsWindow.Show(); SettingsWindow.Focus(); } } However, when I close the SettingsWindow and want to reopen it from the MainWindow, the whole application freezes. I thought the object would be destroyed at closing and thus initialized newly inside the if-clause.
Do I have to do an override in the SettingsWindow's close routine or did I disregard something else?
.ShowDialog()) instead of just another window.SettingsWindow.Show();should display the window again shouldn' it?