Cannot reuse wpf window after closing

Posted by Gaur1982 under WPF on 6/27/2012 | Points: 10 | Views : 6674 | Status : [Member] | Replies : 0
I am using a window to change database configuration for my application. Settings button click is handeled by Config(), it show settings windows when clicked. If I close the using cross sign on the right corner of window, I am not able to reuse the windows it shows following exception.

Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.

ConfigDialogBox configDlg = new ConfigDialogBox();

private void SettingsChanged(object sender, RoutedEventArgs e)
{ =;
Database.port = configDlg.port;
Database.user = configDlg.user;
Database.password = configDlg.password;
Database.database = configDlg.database;
ConfigDlg.Visibility = Visibility.Hidden;

private void Config(object sender, RoutedEventArgs e)
configDlg.okButton.Click+=new RoutedEventHandler(SettingsChanged);
configDlg.cancelButton.Click+=new RoutedEventHandler(SettingsChanged);

void cancel_Click(object sender, RoutedEventArgs e)
ConfigDlg.Visibility = Visibility.Hidden;

How can I reuse it after closing?

Gaurav Agrawal


(No response found.)

Login to post response