Keiron

Keiron

  • NA
  • 5
  • 0

Hiding rather than closing a System.Windows.Window - problem

Jul 12 2007 11:58 AM
Hi all, I want to hide a System.Windows.Window when it is closed (via the [X] control or Alt-F4). I've seen a few different places say that the solution is to handle the Closing event with a CancelEventHandler as such: private void MyWindowClosing(object sender, CancelEventArgs e) { e.Cancel = true; this.Hide(); } However when I do this I get the error: "Cannot set visibility or call Show, ShowDialog, Close or Hide while window is closing." I am using .NET 3.0 and WPF. Am I doing something wrong or is there now a different way to achieve this? Thanks very much, Keiron

Answers (2)