protected void OnViewModelClosing(object sender, EventArgs e) { IViewModel viewModel = (IViewModel)sender; OpenWindows.Remove(viewModel); if (viewModel == CurrentWindow) { CurrentWindow = OpenWindows.FirstOrDefault() ?? defaultWindow; } }