public void CloseModalWindow(WindowType windowType) { openWindows.RemoveAll(w => w == windowType); Messenger.Default.Send <DialogClosedMessage>(new DialogClosedMessage { Sender = this }); System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { if (windowType == WindowType.AddFieldWindow) { addFieldWindow.Close(); } else if (windowType == WindowType.PickupWindow) { pickupWindow.Close(); } else if (windowType == WindowType.LoadingWindow) { loadingWindow.Close(); } else if (windowType == WindowType.UnloadingAtGin) { unloadingAtGinWindow.Close(); } else if (windowType == WindowType.LoadingAtGin) { loadingAtGinWindow.Close(); } else if (windowType == WindowType.LoadingIncorrectModuleWindow) { loadingIncorrectModuleWindow.Close(); } else if (windowType == WindowType.WaitingForUnloadWindow) { waitingForUnloadWindow.Close(); } else if (windowType == WindowType.UnloadCorrectionWindow) { unloadCorrectionWindow.Close(); } else if (windowType == WindowType.ChangeListWindow) { changeFieldWindow.Close(); } else if (windowType == WindowType.TruckSetupWindow) { firstRunWindow.Close(); } })); }