/// <summary> /// Creates a window in non-modal state. If a window with the specified viewModelType exists, the window is activated instead of being created. /// </summary> /// <typeparam name="TViewModel">The view model type.</typeparam> /// <param name="uiVisualizerService">The uiVisualizerService</param> /// <param name="dataContext">The data context.</param> /// <param name="scope">The scope.</param> /// <returns> /// A task. /// </returns> public static async Task ShowOrActivateAsync <TViewModel>(this IUIVisualizerService uiVisualizerService, object dataContext = null, object scope = null) where TViewModel : IViewModel { var dependencyResolver = uiVisualizerService.GetDependencyResolver(); var viewModelManager = dependencyResolver.Resolve <IViewModelManager>(); var viewModelFactory = dependencyResolver.Resolve <IViewModelFactory>(); var existingViewModel = viewModelManager.GetFirstOrDefaultInstance <TViewModel>(); if (existingViewModel != null) { await uiVisualizerService.ShowOrActivateAsync <TViewModel>(dataContext, scope); } else { var vm = viewModelFactory.CreateViewModel(typeof(TViewModel), dataContext, scope); await uiVisualizerService.ShowAsync(vm); } }