private void Window_Closing(object sender, CancelEventArgs e) { DataContext = null; if (Model != null) { Model.Dispose(); Model = null; } }