public static void ShowView(this IBluescreenViewModel bluescreen) { var attribute = bluescreen.GetType().GetCustomAttribute <BluescreenViewAttribute>(); if (attribute is null) { throw new InvalidOperationException("No BluescreenViewAttribute has been found"); } var type = attribute.WindowType; void DispatcherWindowShow() { Application.Current.Dispatcher.Invoke(() => { var window = (Window)Activator.CreateInstance(type, bluescreen); window.ShowOnMonitor(Screen.PrimaryScreen); window.Activate(); window.Focus(); window.Loaded += (sender, _) => (sender as Window)?.Focus(); foreach (var otherScreen in Screen.AllScreens.Where(s => !Equals(s, Screen.PrimaryScreen))) { var blackScreenWindow = new BlackWindow(window); blackScreenWindow.ShowOnMonitor(otherScreen); } return(window); }); } bluescreen.ExecuteCommand.Execute((Action)DispatcherWindowShow); }