public async Task <TResult> ShowDialogAsync <TResult>(DialogViewModel <TResult> viewModel, MetroDialogSettings settings = null)
        {
            var view = ViewLocator.GetViewForViewModel(viewModel);

            var dialog = view as BaseMetroDialog;

            if (dialog == null)
            {
                throw new InvalidOperationException($"The view {view.GetType()} belonging to view model {viewModel.GetType()} does not inherit from {typeof(BaseMetroDialog)}");
            }

            dialog.Resources.MergedDictionaries.Add(new ResourceDictionary {
                Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml")
            });

            var firstMetroWindow = Application.Current.Windows.OfType <MetroWindow>().First();
            await firstMetroWindow.ShowMetroDialogAsync(dialog, settings);

            var result = await viewModel.Task;
            await firstMetroWindow.HideMetroDialogAsync(dialog, settings);

            return(result);
        }